ZQuest Classic Coverage Report


Directory: src/
File: src/zc/guys.cpp
Date: 2025-11-20 06:30:46
Exec Total Coverage
Lines: 9439 12433 75.9%
Functions: 393 441 89.1%
Branches: 7517 13053 57.6%

Line Branch Exec Source
1 #include "base/handles.h"
2 #include "base/scc.h"
3 #include "base/zdefs.h"
4 #include <cstring>
5 #include <optional>
6 #include <stdio.h>
7 #include "base/combo.h"
8 #include "base/general.h"
9 #include "base/zc_alleg.h"
10 #include "zc/guys.h"
11 #include "zc/replay.h"
12 #include "zc/zc_ffc.h"
13 #include "zc/zc_subscr.h"
14 #include "zc/zelda.h"
15 #include "base/zsys.h"
16 #include "base/msgstr.h"
17 #include "zc/maps.h"
18 #include "zc/hero.h"
19 #include "subscr.h"
20 #include "zc/ffscript.h"
21 #include "gamedata.h"
22 #include "defdata.h"
23 #include "zscriptversion.h"
24 #include "particles.h"
25 #include "base/zc_math.h"
26 #include "slopes.h"
27 #include "base/qrs.h"
28 #include "base/dmap.h"
29 #include "base/mapscr.h"
30 #include "base/misctypes.h"
31 #include "base/initdata.h"
32 #include "zc/combos.h"
33 #include "iter.h"
34
35 extern sprite_list guys, items, Ewpns, Lwpns, chainlinks, decorations;
36
37 int32_t repaircharge=0;
38 bool adjustmagic=false;
39 bool learnslash=false;
40 int32_t wallm_load_clk=0;
41 int32_t sle_x,sle_y,sle_cnt,sle_clk=0;
42 int32_t vhead=0;
43
44 char *guy_string[eMAXGUYS];
45
46 void playLevelMusic();
47
48 #define IGNORE_SIDEVIEW_PLATFORMS (editorflags & ENEMY_FLAG14)
49 #define OFFGRID_ENEMY (editorflags & ENEMY_FLAG15)
50
51 1161175 void do_fix(zfix& coord, int32_t val, bool nearest_half = false)
52 {
53 1161175 int32_t c = coord.getInt();
54
2/2
✓ Branch 0 taken 277 times.
✓ Branch 1 taken 1160898 times.
1161175 if(nearest_half)
55 {
56
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1160898 times.
1160898 if (c < 0)
57 c -= val / 2;
58 1160898 else c += (val/2);
59 1160898 }
60 1161175 c -= c % val;
61 1161175 coord = c;
62 1161175 }
63
64 39573070 static bool OUTOFBOUNDS(int32_t id, int32_t x, int32_t y)
65 {
66
4/4
✓ Branch 0 taken 39056464 times.
✓ Branch 1 taken 516606 times.
✓ Branch 2 taken 1215 times.
✓ Branch 3 taken 39571855 times.
39573070 if (y > world_h + (isSideViewGravity() && canfall(id) ? 16 : 176)) return true;
67
2/2
✓ Branch 0 taken 30320 times.
✓ Branch 1 taken 39541535 times.
39571855 if (y < -176) return true;
68
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39541535 times.
39541535 if (x < -256) return true;
69
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 39541454 times.
39541535 if (x > world_w+256) return true;
70 39541454 return false;
71 39573070 }
72
73 bool NEWOUTOFBOUNDS(int32_t x, int32_t y, int32_t z)
74 {
75 return
76 (
77 (y > FFCore.enemy_removal_point[spriteremovalY2])
78 || (y < FFCore.enemy_removal_point[spriteremovalY1])
79 || (x < FFCore.enemy_removal_point[spriteremovalX1])
80 || (x > FFCore.enemy_removal_point[spriteremovalX2])
81 || (z < FFCore.enemy_removal_point[spriteremovalZ1])
82 || (z > FFCore.enemy_removal_point[spriteremovalZ2])
83 );
84 }
85
86 6674 static void position_relative_to_screen(zfix& x, zfix& y, int32_t rx, int32_t ry)
87 {
88 6674 x = rx + (x.getInt()/256)*256;
89 6674 y = ry + (y.getInt()/176)*176;
90 6674 }
91
92 namespace
93 {
94 int32_t trapConstantHorizontalID;
95 int32_t trapConstantVerticalID;
96 int32_t trapLOSHorizontalID;
97 int32_t trapLOSVerticalID;
98 int32_t trapLOS4WayID;
99
100 int32_t cornerTrapID;
101 int32_t centerTrapID;
102
103 int32_t rockID;
104 int32_t zoraID;
105 int32_t statueID;
106 }
107
108 435 void identifyCFEnemies()
109 {
110 435 trapConstantHorizontalID=-1;
111 435 trapConstantVerticalID=-1;
112 435 trapLOSHorizontalID=-1;
113 435 trapLOSVerticalID=-1;
114 435 trapLOS4WayID=-1;
115 435 cornerTrapID=-1;
116 435 centerTrapID=-1;
117 435 rockID=-1;
118 435 zoraID=-1;
119 435 statueID=-1;
120
121
2/2
✓ Branch 0 taken 222720 times.
✓ Branch 1 taken 435 times.
223155 for(int32_t i=0; i<eMAXGUYS; i++)
122 {
123
3/4
✓ Branch 0 taken 430 times.
✓ Branch 1 taken 222290 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 430 times.
222720 if((guysbuf[i].flags&guy_trph) && trapLOSHorizontalID==-1)
124 430 trapLOSHorizontalID=i;
125
4/4
✓ Branch 0 taken 441 times.
✓ Branch 1 taken 222279 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 435 times.
222720 if((guysbuf[i].flags&guy_trpv) && trapLOSVerticalID==-1)
126 435 trapLOSVerticalID=i;
127
3/4
✓ Branch 0 taken 435 times.
✓ Branch 1 taken 222285 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 435 times.
222720 if((guysbuf[i].flags&guy_trp4) && trapLOS4WayID==-1)
128 435 trapLOS4WayID=i;
129
3/4
✓ Branch 0 taken 435 times.
✓ Branch 1 taken 222285 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 435 times.
222720 if((guysbuf[i].flags&guy_trplr) && trapConstantHorizontalID==-1)
130 435 trapConstantHorizontalID=i;
131
3/4
✓ Branch 0 taken 435 times.
✓ Branch 1 taken 222285 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 435 times.
222720 if((guysbuf[i].flags&guy_trpud) && trapConstantVerticalID==-1)
132 435 trapConstantVerticalID=i;
133
134
3/4
✓ Branch 0 taken 435 times.
✓ Branch 1 taken 222285 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 435 times.
222720 if((guysbuf[i].flags&guy_trap) && cornerTrapID==-1)
135 435 cornerTrapID=i;
136
3/4
✓ Branch 0 taken 435 times.
✓ Branch 1 taken 222285 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 435 times.
222720 if((guysbuf[i].flags&guy_trp2) && centerTrapID==-1)
137 435 centerTrapID=i;
138
139
3/4
✓ Branch 0 taken 435 times.
✓ Branch 1 taken 222285 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 435 times.
222720 if((guysbuf[i].flags&guy_rock) && rockID==-1)
140 435 rockID=i;
141
4/4
✓ Branch 0 taken 476 times.
✓ Branch 1 taken 222244 times.
✓ Branch 2 taken 44 times.
✓ Branch 3 taken 432 times.
222720 if((guysbuf[i].flags&guy_zora) && zoraID==-1)
142 432 zoraID=i;
143
144
4/4
✓ Branch 0 taken 552 times.
✓ Branch 1 taken 222168 times.
✓ Branch 2 taken 117 times.
✓ Branch 3 taken 435 times.
222720 if((guysbuf[i].flags & guy_fire) && statueID==-1)
145 435 statueID=i;
146 222720 }
147 435 }
148
149 32 int32_t random_layer_enemy(int screen)
150 {
151 32 int32_t cnt=count_layer_enemies(screen);
152 32 mapscr* base_scr = get_scr(screen);
153
154
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(cnt==0)
155 {
156 return eNONE;
157 }
158
159 32 int32_t ret=zc_oldrand()%cnt;
160 32 cnt=0;
161
162
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 for(int32_t i=0; i<6; ++i)
163 {
164
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(base_scr->layermap[i]!=0)
165 {
166 32 const mapscr* layerscreen = get_canonical_scr(base_scr->layermap[i]-1, base_scr->layerscreen[i]);
167
168
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 for(int32_t j=0; j<10; ++j)
169 {
170
2/4
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 140 times.
140 if(layerscreen->enemy[j]>0&&layerscreen->enemy[j]<MAXGUYS)
171 {
172
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 108 times.
140 if(cnt==ret)
173 {
174 32 return layerscreen->enemy[j];
175 }
176
177 108 ++cnt;
178 108 }
179 108 }
180 }
181 }
182
183 return eNONE;
184 32 }
185
186 49 int32_t count_layer_enemies(int screen)
187 {
188 49 int32_t cnt=0;
189
190 49 mapscr* base_scr = get_scr(screen);
191
192
2/2
✓ Branch 0 taken 294 times.
✓ Branch 1 taken 49 times.
343 for(int32_t i=0; i<6; ++i)
193 {
194
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 79 times.
294 if (base_scr->layermap[i])
195 {
196 79 const mapscr* layerscreen = get_canonical_scr(base_scr->layermap[i]-1, base_scr->layerscreen[i]);
197
198
2/2
✓ Branch 0 taken 790 times.
✓ Branch 1 taken 79 times.
869 for(int32_t j=0; j<10; ++j)
199 {
200
2/2
✓ Branch 0 taken 370 times.
✓ Branch 1 taken 420 times.
790 if(layerscreen->enemy[j]!=0)
201 {
202 420 ++cnt;
203 420 }
204 790 }
205 79 }
206 294 }
207
208 49 return cnt;
209 }
210
211 211789 int32_t hero_on_wall()
212 {
213 211789 zfix lx = Hero.getX();
214 211789 zfix ly = Hero.getY();
215
216
4/4
✓ Branch 0 taken 189837 times.
✓ Branch 1 taken 21952 times.
✓ Branch 2 taken 8850 times.
✓ Branch 3 taken 180987 times.
211789 if(lx>=48 && lx<=world_w-64)
217 {
218
2/2
✓ Branch 0 taken 231 times.
✓ Branch 1 taken 180756 times.
180987 if(ly==32) return up+1;
219
220
2/2
✓ Branch 0 taken 283 times.
✓ Branch 1 taken 180473 times.
180756 if(ly==world_h-48) return down+1;
221 180473 }
222
223
4/4
✓ Branch 0 taken 194033 times.
✓ Branch 1 taken 17242 times.
✓ Branch 2 taken 21403 times.
✓ Branch 3 taken 172630 times.
211275 if(ly>=48 && ly<=world_h-64)
224 {
225
2/2
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 172407 times.
172630 if(lx==32) return left+1;
226
227
2/2
✓ Branch 0 taken 172303 times.
✓ Branch 1 taken 104 times.
172407 if(lx==world_w-48) return right+1;
228 172303 }
229
230 210948 return 0;
231 211789 }
232
233 823532 bool tooclose(int32_t x,int32_t y,int32_t d)
234 {
235
2/2
✓ Branch 0 taken 613233 times.
✓ Branch 1 taken 210299 times.
823532 return (abs(int32_t(HeroX())-x)<d && abs(int32_t(HeroY())-y)<d);
236 }
237
238 4170490 bool enemy::overpit() const
239 {
240 // This function (and shadow_overpit) has been broken since it was written, and only
241 // checked the same diagonal of the hitbox, over and over again. The bug is because both
242 // loops used the same variable name.
243 // Checking literally every pixel seems like overkill, so for now let's continue to
244 // do the single diagonal but just once. That's why the outer loop is commented out.
245
246 // for ( int32_t q = 0; q < hxsz; ++q )
247 {
248
2/2
✓ Branch 0 taken 38357256 times.
✓ Branch 1 taken 4142742 times.
42499998 for ( int32_t q = 0; q < hit_height; ++q )
249 {
250 //check every pixel of the hitbox
251
2/2
✓ Branch 0 taken 27748 times.
✓ Branch 1 taken 38329508 times.
38357256 if ( ispitfall(x+q+hxofs, y+q+hyofs) )
252 {
253 //if the hitbox is over a pit, we can't land
254 27748 return true;
255 }
256 38329508 }
257 }
258 4142742 return false;
259 4170490 }
260
261 2738192 bool enemy::shadow_overpit() const
262 {
263 // for ( int32_t q = 0; q < hxsz; ++q )
264 {
265
2/2
✓ Branch 0 taken 33489077 times.
✓ Branch 1 taken 2716587 times.
36205664 for ( int32_t q = 0; q < hit_height; ++q )
266 {
267 //check every pixel of the hitbox
268
2/2
✓ Branch 0 taken 21605 times.
✓ Branch 1 taken 33467472 times.
33489077 if ( ispitfall(x+q+hxofs, y+q+hyofs+hit_height-2) )
269 {
270 //if the hitbox is over a pit, we can't land
271 21605 return true;
272 }
273 33467472 }
274 }
275 2716587 return false;
276 2738192 }
277
278 // Returns true iff a combo type or flag precludes enemy movement.
279 9645414 bool enemy::groundblocked(int32_t dx, int32_t dy, bool isKB)
280 {
281
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9645414 times.
9645414 if(moveflags & move_ignore_blockflags) return false;
282 9645414 int32_t c = COMBOTYPE(dx,dy);
283
4/4
✓ Branch 0 taken 6357351 times.
✓ Branch 1 taken 3288063 times.
✓ Branch 2 taken 1472123 times.
✓ Branch 3 taken 1815940 times.
12933477 bool pit_blocks = (!(moveflags & (move_can_pitwalk|move_only_pitwalk)) && (!(moveflags & move_can_pitfall) || !isKB));
284
6/6
✓ Branch 0 taken 3263934 times.
✓ Branch 1 taken 6381480 times.
✓ Branch 2 taken 408602 times.
✓ Branch 3 taken 2855332 times.
✓ Branch 4 taken 28668 times.
✓ Branch 5 taken 379934 times.
9645414 bool water_blocks = (!(moveflags & (move_can_waterwalk|move_only_waterwalk|move_only_shallow_waterwalk)) && (!(moveflags & move_can_waterdrown) || !isKB) && get_qr(qr_DROWN));
285
5/6
✓ Branch 0 taken 3379441 times.
✓ Branch 1 taken 6265973 times.
✓ Branch 2 taken 3377564 times.
✓ Branch 3 taken 1877 times.
✓ Branch 4 taken 3377564 times.
✗ Branch 5 not taken.
19291592 return c==cPIT || c==cPITB || c==cPITC ||
286
4/6
✓ Branch 0 taken 3377564 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3377564 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3139583 times.
✓ Branch 5 taken 237981 times.
3377564 c==cPITD || c==cPITR || (pit_blocks && ispitfall(dx,dy)) ||
287 // Block enemies type and block enemies flags
288
2/2
✓ Branch 0 taken 3372288 times.
✓ Branch 1 taken 3134307 times.
237981 combo_class_buf[c].block_enemies&1 ||
289
4/4
✓ Branch 0 taken 3360260 times.
✓ Branch 1 taken 12028 times.
✓ Branch 2 taken 3360013 times.
✓ Branch 3 taken 247 times.
3372288 MAPFLAG(dx,dy)==mfNOENEMY || MAPCOMBOFLAG(dx,dy)==mfNOENEMY ||
290
4/4
✓ Branch 0 taken 3357316 times.
✓ Branch 1 taken 2697 times.
✓ Branch 2 taken 3357250 times.
✓ Branch 3 taken 66 times.
3360013 MAPFLAG(dx,dy)==mfNOGROUNDENEMY || MAPCOMBOFLAG(dx,dy)==mfNOGROUNDENEMY ||
291 // Check for ladder-only combos which aren't dried water
292
4/4
✓ Branch 0 taken 54223 times.
✓ Branch 1 taken 3303027 times.
✓ Branch 2 taken 53928 times.
✓ Branch 3 taken 295 times.
6714205 (combo_class_buf[c].ladder_pass&1 && !iswater_type(c)) ||
293 // Check for drownable water
294
4/4
✓ Branch 0 taken 1274561 times.
✓ Branch 1 taken 2082394 times.
✓ Branch 2 taken 2332 times.
✓ Branch 3 taken 1272229 times.
3356955 (water_blocks && !(isSideViewGravity()) && (iswaterex_z3(MAPCOMBO(dx,dy), -1, dx, dy, false, false, true, false, false)));
295 3382082 }
296
297 // Returns true iff enemy is floating and blocked by a combo type or flag.
298 9073786 bool enemy::flyerblocked(int32_t dx, int32_t dy, int32_t special, bool isKB)
299 {
300
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9073786 times.
9073786 if(moveflags & move_ignore_blockflags) return false;
301
4/4
✓ Branch 0 taken 6934805 times.
✓ Branch 1 taken 2138981 times.
✓ Branch 2 taken 1750538 times.
✓ Branch 3 taken 388443 times.
11212767 bool pit_blocks = (!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall) || !isKB));
302
4/4
✓ Branch 0 taken 6949352 times.
✓ Branch 1 taken 2124434 times.
✓ Branch 2 taken 2097157 times.
✓ Branch 3 taken 27277 times.
11198220 bool water_blocks = (!(moveflags & move_can_waterwalk) && (!(moveflags & move_can_waterdrown) || !isKB));
303
2/2
✓ Branch 0 taken 1265400 times.
✓ Branch 1 taken 7808386 times.
16882172 return ((special==spw_floater)&&
304
2/2
✓ Branch 0 taken 7797980 times.
✓ Branch 1 taken 10406 times.
7808386 ((COMBOTYPE(dx,dy)==cNOFLYZONE)||
305
2/2
✓ Branch 0 taken 7797861 times.
✓ Branch 1 taken 119 times.
7797980 (combo_class_buf[COMBOTYPE(dx,dy)].block_enemies&4)||
306
2/2
✓ Branch 0 taken 7790050 times.
✓ Branch 1 taken 7811 times.
7797861 (MAPFLAG(dx,dy)==mfNOENEMY)||
307
2/2
✓ Branch 0 taken 7789795 times.
✓ Branch 1 taken 255 times.
7790050 (MAPCOMBOFLAG(dx,dy)==mfNOENEMY)||
308
4/4
✓ Branch 0 taken 1242529 times.
✓ Branch 1 taken 6547266 times.
✓ Branch 2 taken 4004 times.
✓ Branch 3 taken 1238525 times.
15575586 (water_blocks && iswaterex_z3(MAPCOMBO(dx, dy), -1, dx,dy, false, false, true)) ||
309
2/2
✓ Branch 0 taken 6537677 times.
✓ Branch 1 taken 1248114 times.
7785791 (pit_blocks && ispitfall(dx,dy))));
310 9073786 }
311 // Returns true iff a combo type or flag precludes enemy movement.
312 287854 bool groundblocked(int32_t dx, int32_t dy, guydata const& gd)
313 {
314 287854 int32_t c = COMBOTYPE(dx,dy);
315 287854 bool pit_blocks = !(gd.moveflags & move_can_pitwalk);
316
2/2
✓ Branch 0 taken 35642 times.
✓ Branch 1 taken 252212 times.
287854 bool water_blocks = !(gd.moveflags & move_can_waterwalk) && get_qr(qr_DROWN);
317
5/6
✓ Branch 0 taken 287834 times.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 287717 times.
✓ Branch 3 taken 117 times.
✓ Branch 4 taken 287717 times.
✗ Branch 5 not taken.
1085745 return c==cPIT || c==cPITB || c==cPITC ||
318
4/6
✓ Branch 0 taken 287717 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 287717 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 255757 times.
✓ Branch 5 taken 31960 times.
287717 c==cPITD || c==cPITR || (pit_blocks && ispitfall(dx,dy)) ||
319 // Block enemies type and block enemies flags
320
2/2
✓ Branch 0 taken 287047 times.
✓ Branch 1 taken 255087 times.
31960 combo_class_buf[c].block_enemies&1 ||
321
4/4
✓ Branch 0 taken 285788 times.
✓ Branch 1 taken 1259 times.
✓ Branch 2 taken 285757 times.
✓ Branch 3 taken 31 times.
287047 MAPFLAG(dx,dy)==mfNOENEMY || MAPCOMBOFLAG(dx,dy)==mfNOENEMY ||
322
4/4
✓ Branch 0 taken 281591 times.
✓ Branch 1 taken 4166 times.
✓ Branch 2 taken 281316 times.
✓ Branch 3 taken 275 times.
285757 MAPFLAG(dx,dy)==mfNOGROUNDENEMY || MAPCOMBOFLAG(dx,dy)==mfNOGROUNDENEMY ||
323 // Check for ladder-only combos which aren't dried water
324
4/4
✓ Branch 0 taken 1813 times.
✓ Branch 1 taken 279503 times.
✓ Branch 2 taken 1774 times.
✓ Branch 3 taken 39 times.
562593 (combo_class_buf[c].ladder_pass&1 && !iswater_type(c)) ||
325 // Check for drownable water
326
4/4
✓ Branch 0 taken 57405 times.
✓ Branch 1 taken 223872 times.
✓ Branch 2 taken 28535 times.
✓ Branch 3 taken 28870 times.
281277 (water_blocks && !(isSideViewGravity()) && (iswaterex_z3(MAPCOMBO(dx,dy), -1, dx, dy, false, false, true)));
327 }
328
329 // Returns true iff enemy is floating and blocked by a combo type or flag.
330 144461 bool flyerblocked(int32_t dx, int32_t dy, int32_t special, guydata const& gd)
331 {
332
2/2
✓ Branch 0 taken 142138 times.
✓ Branch 1 taken 2323 times.
144461 bool pit_blocks = (!(gd.moveflags & move_can_pitwalk) && !(gd.moveflags & move_can_pitfall));
333 144461 bool water_blocks = !(gd.moveflags & move_can_waterwalk);
334
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144461 times.
288922 return ((special==spw_floater)&&
335
2/2
✓ Branch 0 taken 144299 times.
✓ Branch 1 taken 162 times.
144461 ((COMBOTYPE(dx,dy)==cNOFLYZONE)||
336
2/2
✓ Branch 0 taken 143664 times.
✓ Branch 1 taken 635 times.
144299 (combo_class_buf[COMBOTYPE(dx,dy)].block_enemies&4)||
337
2/2
✓ Branch 0 taken 140745 times.
✓ Branch 1 taken 2919 times.
143664 (MAPFLAG(dx,dy)==mfNOENEMY)||
338
2/2
✓ Branch 0 taken 140716 times.
✓ Branch 1 taken 29 times.
140745 (MAPCOMBOFLAG(dx,dy)==mfNOENEMY)||
339
4/4
✓ Branch 0 taken 2321 times.
✓ Branch 1 taken 138395 times.
✓ Branch 2 taken 250 times.
✓ Branch 3 taken 2071 times.
281182 (water_blocks && iswaterex_z3(MAPCOMBO(dx,dy), -1, dx, dy, false, false, true)) ||
340
2/2
✓ Branch 0 taken 138395 times.
✓ Branch 1 taken 2071 times.
140466 (pit_blocks && ispitfall(dx,dy))));
341 }
342
343
5/10
✓ Branch 0 taken 119190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119190 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 119190 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 119190 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 119190 times.
✗ Branch 9 not taken.
238380 enemy::enemy(zfix X,zfix Y,int32_t Id,int32_t Clk) : sprite()
344 119190 {
345
1/2
✓ Branch 0 taken 119190 times.
✗ Branch 1 not taken.
119190 x=X;
346
1/2
✓ Branch 0 taken 119190 times.
✗ Branch 1 not taken.
119190 y=Y;
347
3/6
✓ Branch 0 taken 119190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119190 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 119190 times.
✗ Branch 5 not taken.
119190 screen_spawned=get_screen_for_world_xy(x.getInt(), y.getInt());
348 119190 id=Id;
349 119190 clk=Clk;
350
1/2
✓ Branch 0 taken 119190 times.
✗ Branch 1 not taken.
119190 floor_y=y;
351 119190 ceiling=false;
352 119190 fading = misc = clk2 = clk3 = stunclk = hclk = sclk = superman = 0;
353 119190 grumble = movestatus = posframe = timer = ox = oy = 0;
354
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 119190 times.
✓ Branch 2 taken 119190 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 119190 times.
✗ Branch 5 not taken.
119190 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) - ((isSideViewGravity()) ? 0 : 2);
355 119190 did_armos=true;
356 119190 script_spawned=false;
357
358 119190 d = guysbuf + (id & 0xFFF);
359 119190 hp = d->hp;
360 119190 starting_hp = hp;
361 // cs = d->cset;
362 //d variables
363
364 119190 flags=d->flags;
365 119190 flags=d->flags;
366 119190 s_tile=d->s_tile; //secondary (additional) tile(s)
367 119190 type=d->type;
368 119190 dcset=d->cset;
369 119190 cs=dcset;
370
2/2
✓ Branch 0 taken 93046 times.
✓ Branch 1 taken 26144 times.
119190 anim=get_qr(qr_NEWENEMYTILES)?d->e_anim:d->anim;
371 119190 dp=d->dp;
372 119190 wdp=d->wdp;
373 119190 wpn=d->weapon;
374 119190 wpnsprite = d-> wpnsprite; //2.6 -Z
375 119190 rate=d->rate;
376 119190 hrate=d->hrate;
377
1/2
✓ Branch 0 taken 119190 times.
✗ Branch 1 not taken.
119190 dstep=d->step;
378 119190 homing=d->homing;
379 119190 dmisc1=d->attributes[0];
380 119190 dmisc2=d->attributes[1];
381 119190 dmisc3=d->attributes[2];
382 119190 dmisc4=d->attributes[3];
383 119190 dmisc5=d->attributes[4];
384 119190 dmisc6=d->attributes[5];
385 119190 dmisc7=d->attributes[6];
386 119190 dmisc8=d->attributes[7];
387 119190 dmisc9=d->attributes[8];
388 119190 dmisc10=d->attributes[9];
389 119190 dmisc11=d->attributes[10];
390 119190 dmisc12=d->attributes[11];
391 119190 dmisc13=d->attributes[12];
392 119190 dmisc14=d->attributes[13];
393 119190 dmisc15=d->attributes[14];
394 119190 dmisc16=d->attributes[15];
395 119190 dmisc17=d->attributes[16];
396 119190 dmisc18=d->attributes[17];
397 119190 dmisc19=d->attributes[18];
398 119190 dmisc20=d->attributes[19];
399 119190 dmisc21=d->attributes[20];
400 119190 dmisc22=d->attributes[21];
401 119190 dmisc23=d->attributes[22];
402 119190 dmisc24=d->attributes[23];
403 119190 dmisc25=d->attributes[24];
404 119190 dmisc26=d->attributes[25];
405 119190 dmisc27=d->attributes[26];
406 119190 dmisc28=d->attributes[27];
407 119190 dmisc29=d->attributes[28];
408 119190 dmisc30=d->attributes[29];
409 119190 dmisc31=d->attributes[30];
410 119190 dmisc32=d->attributes[31];
411
2/2
✓ Branch 0 taken 8225 times.
✓ Branch 1 taken 110965 times.
119190 if (get_qr(qr_BROKEN_ATTRIBUTE_31_32))
412 {
413 110965 dmisc31 = dmisc32;
414 110965 dmisc32 = 0;
415 110965 }
416 119190 spr_shadow=d->spr_shadow;
417 119190 spr_death=d->spr_death;
418 119190 spr_spawn=d->spr_spawn;
419
420
2/2
✓ Branch 0 taken 4886790 times.
✓ Branch 1 taken 119190 times.
5005980 for(int32_t i=0; i<edefLAST255; i++)
421 4886790 defense[i]=d->defense[i];
422
423 119190 bgsfx=d->bgsfx;
424 119190 hitsfx=d->hitsfx;
425 119190 deadsfx=d->deadsfx;
426 119190 bosspal=d->bosspal;
427
428 119190 frozentile = d->frozentile;
429
430 119190 frozencset = d->frozencset;
431 119190 frozenclock = 0;
432
2/2
✓ Branch 0 taken 1191900 times.
✓ Branch 1 taken 119190 times.
1311090 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = d->frozenmisc[q];
433
434
2/2
✓ Branch 0 taken 2026230 times.
✓ Branch 1 taken 119190 times.
2145420 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = 0;
435 //firesfx = 0; //t.b.a -Z
436 119190 isCore = true; //t.b.a
437 119190 parentCore = 0; //t.b.a
438
439 119190 firesfx = d->firesfx;
440
2/2
✓ Branch 0 taken 3814080 times.
✓ Branch 1 taken 119190 times.
3933270 for ( int32_t q = 0; q < 32; q++ ) movement[q] = d->movement[q];
441
2/2
✓ Branch 0 taken 3814080 times.
✓ Branch 1 taken 119190 times.
3933270 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = d->new_weapon[q];
442
443 119190 script = d->script;
444
445
2/2
✓ Branch 0 taken 953520 times.
✓ Branch 1 taken 119190 times.
1072710 for ( int32_t q = 0; q < 8; q++ )
446 {
447 953520 initD[q] = d->initD[q];
448 953520 }
449
450 119190 stickclk = 0;
451 119190 submerged = false;
452 119190 didScriptThisFrame = false;
453 119190 activated_handle = std::nullopt;
454 119190 hitdir = -1;
455 119190 editorflags = d->editorflags; //set by Enemy Editor
456 //Set the drawing flag for this sprite.
457
1/2
✓ Branch 0 taken 119190 times.
✗ Branch 1 not taken.
119190 if ( (editorflags&ENEMY_FLAG12) ) { drawflags |= sprdrawflagALWAYSOLDDRAWS; }
458
459
460
2/2
✓ Branch 0 taken 8927 times.
✓ Branch 1 taken 110263 times.
119190 if(bosspal>-1)
461 {
462
1/2
✓ Branch 0 taken 8927 times.
✗ Branch 1 not taken.
8927 loadpalset(csBOSS,pSprite(bosspal));
463 8927 }
464
465
2/2
✓ Branch 0 taken 54277 times.
✓ Branch 1 taken 64913 times.
119190 if(bgsfx>-1)
466 {
467
1/2
✓ Branch 0 taken 54277 times.
✗ Branch 1 not taken.
54277 cont_sfx(bgsfx);
468 54277 }
469
470
2/2
✓ Branch 0 taken 93046 times.
✓ Branch 1 taken 26144 times.
119190 if(get_qr(qr_NEWENEMYTILES))
471 {
472 93046 o_tile=d->e_tile;
473 93046 frate = d->e_frate;
474 93046 }
475 else
476 {
477 26144 o_tile=d->tile;
478 26144 frate = d->frate;
479 }
480
481 119190 tile=0; //init to 0 here, but set it later.
482
483 119190 scripttile = -1;
484 119190 scriptflip = -1;
485 119190 do_animation = true;
486 119190 immortal = false;
487 119190 noSlide = false;
488 119190 deathexstate = -1;
489
490 119190 hashero=false;
491
492 // If they forgot the invisibility flag, here's another failsafe:
493
4/4
✓ Branch 0 taken 5798 times.
✓ Branch 1 taken 113392 times.
✓ Branch 2 taken 5704 times.
✓ Branch 3 taken 94 times.
119190 if(o_tile==0 && type!=eeSPINTILE)
494
1/2
✓ Branch 0 taken 5704 times.
✗ Branch 1 not taken.
5704 flags |= guy_invisible;
495
496 // step = d->step/100.0;
497 // To preserve the odd step values for Keese & Gleeok heads. -L
498
5/8
✓ Branch 0 taken 119190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119190 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12948 times.
✓ Branch 5 taken 106242 times.
✓ Branch 6 taken 12948 times.
✗ Branch 7 not taken.
119190 if(dstep==62.0) dstep+=0.5;
499
5/8
✓ Branch 0 taken 106242 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106242 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 699 times.
✓ Branch 5 taken 105543 times.
✓ Branch 6 taken 699 times.
✗ Branch 7 not taken.
106242 else if(dstep==89) dstep-=1/9;
500
501
5/10
✓ Branch 0 taken 119190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119190 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 119190 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 119190 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 119190 times.
✗ Branch 9 not taken.
119190 step = zslongToFix(dstep*100);
502
503
504 119190 item_set = d->item_set;
505 119190 grumble = d->grumble;
506
507
2/2
✓ Branch 0 taken 93553 times.
✓ Branch 1 taken 25637 times.
119190 if(frate == 0)
508 25637 frate = 256;
509
510 119190 leader = itemguy = dying = scored = false;
511 119190 canfreeze = count_enemy = true;
512
1/2
✓ Branch 0 taken 119190 times.
✗ Branch 1 not taken.
119190 mainguy = !(flags & guy_doesnt_count);
513
1/2
✓ Branch 0 taken 119190 times.
✗ Branch 1 not taken.
119190 dir = zc_oldrand()&3;
514
515 //2.6 Enemy Editor Hit and TIle Sizes
516
4/6
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 119151 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 39 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 39 times.
119190 if ( ((d->SIZEflags&OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
517 // al_trace("Enemy txsz:%i\n", txsz);
518
5/6
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 119151 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 39 times.
✓ Branch 4 taken 23 times.
✓ Branch 5 taken 16 times.
119190 if ( ((d->SIZEflags&OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
519
3/4
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 119153 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 37 times.
119190 if ( ((d->SIZEflags&OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hit_width = d->hxsz;
520
3/4
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 119153 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 37 times.
119190 if ( ((d->SIZEflags&OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hit_height = d->hysz;
521
3/4
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 119167 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 23 times.
119190 if ( ((d->SIZEflags&OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
522
2/2
✓ Branch 0 taken 119162 times.
✓ Branch 1 taken 28 times.
119190 if ( (d->SIZEflags&OVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
523
2/2
✓ Branch 0 taken 119162 times.
✓ Branch 1 taken 28 times.
119190 if ( (d->SIZEflags&OVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
524 // if ( (d->SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = d->hzofs;
525
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 119188 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
119190 if ( (d->SIZEflags&OVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
526
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 119188 times.
119190 if ( (d->SIZEflags&OVERRIDE_DRAW_Y_OFFSET) != 0 )
527 {
528
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
529
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
530 2 }
531
532
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 119188 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
119190 if ( (d->SIZEflags&OVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
533
534 119190 SIZEflags = d->SIZEflags;
535
536
8/10
✓ Branch 0 taken 118939 times.
✓ Branch 1 taken 251 times.
✓ Branch 2 taken 368 times.
✓ Branch 3 taken 118822 times.
✓ Branch 4 taken 368 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 368 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 367 times.
119190 if((wpn==ewBomb || wpn==ewSBomb) && type!=eeOTHER && type!=eeFIRE && (type!=eeWALK || dmisc2 != e2tBOMBCHU))
537 1 wpn = 0;
538
539 //tile should never be 0 after init --Z (failsafe)
540
4/6
✓ Branch 0 taken 119190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119190 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 107998 times.
✓ Branch 5 taken 11192 times.
119190 if (tile <= 0 && FFCore.getQuestHeaderInfo(vZelda) >= 0x255) {tile = o_tile;}
541
542 //Moveflags; for gravity and pit interaction
543 119190 moveflags = d->moveflags;
544
3/4
✓ Branch 0 taken 119190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17800 times.
✓ Branch 3 taken 101390 times.
119190 if(!can_pitfall(false))
545 {
546 //Some enemies must not interact with pits. Force their flags, for sanity's sake.
547
2/4
✓ Branch 0 taken 17800 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17800 times.
✗ Branch 3 not taken.
17800 moveflags &= ~move_can_pitfall;
548
2/4
✓ Branch 0 taken 17800 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17800 times.
✗ Branch 3 not taken.
17800 moveflags &= ~move_can_waterdrown;
549 17800 }
550
551 119190 shieldCanBlock = get_qr(qr_GOHMA_UNDAMAGED_BUG)?true:false;
552
553 119190 specialsfx = d->specialsfx;
554
1/2
✓ Branch 0 taken 119190 times.
✗ Branch 1 not taken.
119190 weap_data = d->weap_data;
555 119190 }
556
557 118928 enemy::~enemy()
558 118928 {
559
1/2
✓ Branch 0 taken 118928 times.
✗ Branch 1 not taken.
118928 FFCore.destroySprite(this);
560
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 118914 times.
118928 if(hashero)
561 {
562
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 Hero.setEaten(0);
563 14 hashero=false;
564 14 }
565 118928 }
566
567 bool enemy::is_move_paused()
568 {
569 return (clk<0 || dying || stunclk || watch || ceiling || frozenclock || fallclk || drownclk);
570 }
571
572 396782 bool enemy::scr_walkflag(int32_t dx,int32_t dy,int32_t special, int32_t dir, int32_t input_x, int32_t input_y, bool kb)
573 {
574 396782 int32_t yg = (special==spw_floater)?8:0;
575 396782 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
576
577
1/2
✓ Branch 0 taken 396782 times.
✗ Branch 1 not taken.
396782 if(input_x == -1000)
578 input_x = dx;
579
1/2
✓ Branch 0 taken 396782 times.
✗ Branch 1 not taken.
396782 if(input_y == -1000)
580 input_y = dy;
581
582
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 396454 times.
793287 if(!(moveflags & move_ignore_screenedge)
583
5/6
✓ Branch 0 taken 396782 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 76 times.
✓ Branch 3 taken 396706 times.
✓ Branch 4 taken 335178 times.
✓ Branch 5 taken 61528 times.
396782 && ((input_x<(16-nb)) || (input_y<zc_max(16-yg-nb,0))
584
4/4
✓ Branch 0 taken 396556 times.
✓ Branch 1 taken 150 times.
✓ Branch 2 taken 396505 times.
✓ Branch 3 taken 51 times.
396706 || ((input_x+hit_width-1) >= (world_w-16+nb)) || ((input_y+hit_height-1) >= (world_h-16+nb))))
585 328 return true;
586
587
6/6
✓ Branch 0 taken 278162 times.
✓ Branch 1 taken 118292 times.
✓ Branch 2 taken 207763 times.
✓ Branch 3 taken 70399 times.
✓ Branch 4 taken 1967 times.
✓ Branch 5 taken 205796 times.
396454 if(!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall) || !kb)) //Don't walk into pits, unless being knocked back
588 {
589
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 276195 times.
276195 if(ispitfall(dx,dy))
590 return true;
591 276195 }
592
593 396454 bool flying = false;
594 396454 bool cansolid = false;
595
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 396454 times.
396454 if(moveflags & move_ignore_solidity)
596 cansolid = true;
597
2/4
✓ Branch 0 taken 61519 times.
✓ Branch 1 taken 334935 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
396454 switch(special)
598 {
599 case spw_clipbottomright:
600 if(dy>=128 || dx>=208) return true;
601 break;
602 case spw_clipright:
603 break; //if(input_x>=208) return true; break;
604
605 case spw_wizzrobe: // fall through
606 case spw_floater: // Special case for fliers and wizzrobes - hack!
607 {
608
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 61519 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
61519 if(isdungeon(screen_spawned) && !(moveflags & move_ignore_screenedge))
609 {
610 if(dy < 32-yg || dy >= 144) return true;
611 if(dx < 32 || dx >= 224) return true;
612 }
613
3/4
✓ Branch 0 taken 61519 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57803 times.
✓ Branch 3 taken 3716 times.
61519 if(!(moveflags & move_ignore_blockflags) && flyerblocked(dx, dy, special, kb))
614 3716 return true;
615 57803 cansolid = true;
616 57803 flying = true;
617 }
618 57803 }
619
620 392738 dx = TRUNCATE_HALF_TILE(dx);
621 392738 dy = TRUNCATE_HALF_TILE(dy);
622
623
5/6
✓ Branch 0 taken 334935 times.
✓ Branch 1 taken 57803 times.
✓ Branch 2 taken 334935 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 298582 times.
✓ Branch 5 taken 36353 times.
392738 if(!flying && !(moveflags & move_ignore_blockflags) && groundblocked(dx,dy,kb)) return true;
624
625
4/8
✓ Branch 0 taken 356385 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 356385 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 356385 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 356385 times.
356385 if (dx < 0 || dx >= world_w || dy < 0 || dy >= world_h)
626 return !(moveflags & move_ignore_screenedge);
627
628 // TODO: could this reuse _walkflag?
629
630 //_walkflag code
631 356385 mapscr* s0 = get_scr_for_world_xy_layer(dx, dy, 0);
632
1/2
✓ Branch 0 taken 356385 times.
✗ Branch 1 not taken.
356385 mapscr* s1 = s0->layermap[0]-1 >= 0 ? get_scr_for_world_xy_layer(dx, dy, 1) : nullptr;
633
2/2
✓ Branch 0 taken 350399 times.
✓ Branch 1 taken 5986 times.
356385 mapscr* s2 = s0->layermap[1]-1 >= 0 ? get_scr_for_world_xy_layer(dx, dy, 2) : nullptr;
634
2/4
✓ Branch 0 taken 356385 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 356385 times.
✗ Branch 3 not taken.
356385 if (!s1 || !s1->valid) s1 = s0;
635
3/4
✓ Branch 0 taken 350399 times.
✓ Branch 1 taken 5986 times.
✓ Branch 2 taken 350399 times.
✗ Branch 3 not taken.
356385 if (!s2 || !s2->valid) s2 = s0;
636
637 356385 int32_t cpos = COMBOPOS(dx%256, dy%176);
638
2/4
✓ Branch 0 taken 356385 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 356385 times.
✗ Branch 3 not taken.
356385 int32_t ci = s0->data[cpos], ci1 = (s1?s1:s0)->data[cpos], ci2 = (s2?s2:s0)->data[cpos];
639 356385 newcombo c = combobuf[ci];
640
1/2
✓ Branch 0 taken 356385 times.
✗ Branch 1 not taken.
356385 newcombo c1 = combobuf[ci1];
641
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 356385 times.
356385 newcombo c2 = combobuf[ci2];
642
643 356385 int32_t b=1;
644
2/2
✓ Branch 0 taken 170119 times.
✓ Branch 1 taken 186266 times.
356385 if(dx&8) b<<=2;
645
2/2
✓ Branch 0 taken 167084 times.
✓ Branch 1 taken 189301 times.
356385 if(dy&8) b<<=1;
646
647 #define iwtr(cmb, x, y, shallow) \
648 (shallow \
649 ? iswaterex_z3(cmb, -1, dx, dy, false, false, false, true, false) \
650 && !iswaterex_z3(cmb, -1, dx, dy, false, false, false, false, false) \
651 : iswaterex_z3(cmb, -1, dx, dy, false, false, false, false, false))
652
1/2
✓ Branch 0 taken 356385 times.
✗ Branch 1 not taken.
356385 bool wtr = iwtr(ci, dx, dy, false);
653
4/6
✓ Branch 0 taken 356385 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 45689 times.
✓ Branch 3 taken 310696 times.
✓ Branch 4 taken 45689 times.
✗ Branch 5 not taken.
356385 bool shwtr = iwtr(ci, dx, dy, true);
654
1/2
✓ Branch 0 taken 356385 times.
✗ Branch 1 not taken.
356385 bool pit = ispitfall(dx,dy);
655
656
6/8
✓ Branch 0 taken 356385 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 236798 times.
✓ Branch 3 taken 119587 times.
✓ Branch 4 taken 236798 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 82587 times.
✓ Branch 7 taken 154211 times.
356385 bool canwtr = (moveflags & move_can_waterwalk) || ((moveflags & move_can_waterdrown) && kb);
657
6/8
✓ Branch 0 taken 356385 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 241968 times.
✓ Branch 3 taken 114417 times.
✓ Branch 4 taken 241968 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 70399 times.
✓ Branch 7 taken 171569 times.
356385 bool canpit = (moveflags & move_can_pitwalk) || ((moveflags & move_can_pitfall) && kb);
658
1/2
✓ Branch 0 taken 356385 times.
✗ Branch 1 not taken.
356385 bool needwtr = (moveflags & move_only_waterwalk);
659
1/2
✓ Branch 0 taken 356385 times.
✗ Branch 1 not taken.
356385 bool needshwtr = (moveflags & move_only_shallow_waterwalk);
660
1/2
✓ Branch 0 taken 356385 times.
✗ Branch 1 not taken.
356385 bool needpit = (moveflags & move_only_pitwalk);
661
662
2/2
✓ Branch 0 taken 57803 times.
✓ Branch 1 taken 298582 times.
356385 if(!cansolid)
663 {
664 298582 int32_t cwalkflag = c.walk & 0xF;
665
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 298582 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
298582 if (c.type == cBRIDGE && get_qr(qr_OLD_BRIDGE_COMBOS)) cwalkflag = 0;
666
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 298582 times.
298582 if (s1)
667 {
668
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 298582 times.
298582 if (c1.type == cBRIDGE)
669 {
670 if (!get_qr(qr_OLD_BRIDGE_COMBOS))
671 {
672 int efflag = (c1.walk & 0xF0)>>4;
673 int newsolid = (c1.walk & 0xF);
674 cwalkflag = ((newsolid | cwalkflag) & (~efflag)) | (newsolid & efflag);
675 }
676 else cwalkflag &= c1.walk;
677 }
678 298582 else cwalkflag |= c1.walk & 0xF;
679 298582 }
680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 298582 times.
298582 if (s2)
681 {
682
2/2
✓ Branch 0 taken 1261 times.
✓ Branch 1 taken 297321 times.
298582 if (c2.type == cBRIDGE)
683 {
684
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1261 times.
1261 if (!get_qr(qr_OLD_BRIDGE_COMBOS))
685 {
686 1261 int efflag = (c2.walk & 0xF0)>>4;
687 1261 int newsolid = (c2.walk & 0xF);
688 1261 cwalkflag = ((newsolid | cwalkflag) & (~efflag)) | (newsolid & efflag);
689 1261 }
690 else cwalkflag &= c2.walk;
691 1261 }
692 297321 else cwalkflag |= c2.walk & 0xF;
693 298582 }
694
2/2
✓ Branch 0 taken 50862 times.
✓ Branch 1 taken 247720 times.
298582 if(cwalkflag & b)
695 50862 return true;
696 247720 }
697
3/6
✓ Branch 0 taken 305523 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 305523 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 305523 times.
305523 if(needwtr || needshwtr || needpit)
698 {
699 bool ret = true;
700 if (needwtr && wtr) ret = false;
701 else if (needshwtr && shwtr) ret = false;
702 else if (needpit && pit) ret = false;
703 return ret;
704 }
705
3/4
✓ Branch 0 taken 22544 times.
✓ Branch 1 taken 282979 times.
✓ Branch 2 taken 22544 times.
✗ Branch 3 not taken.
305523 else if(wtr && !canwtr)
706 return true;
707
3/4
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 305400 times.
✓ Branch 2 taken 123 times.
✗ Branch 3 not taken.
305523 else if(pit && !canpit)
708 return true;
709
710 305523 return false;
711 396782 }
712
713 181035 bool enemy::scr_canmove(zfix dx, zfix dy, int32_t special, bool kb, bool ign_sv)
714 {
715
3/4
✓ Branch 0 taken 93117 times.
✓ Branch 1 taken 87918 times.
✓ Branch 2 taken 93117 times.
✗ Branch 3 not taken.
181035 if(!(dx || dy)) return true;
716 181035 zfix bx = x+hxofs, by = y+hyofs; //left/top
717 181035 zfix rx = bx+hit_width-1, ry = by+hit_height-1; //right/bottom
718
4/4
✓ Branch 0 taken 178930 times.
✓ Branch 1 taken 2105 times.
✓ Branch 2 taken 131817 times.
✓ Branch 3 taken 47113 times.
181035 if(!ign_sv && dy < 0) //check gravity
719 {
720
3/4
✓ Branch 0 taken 40102 times.
✓ Branch 1 taken 7011 times.
✓ Branch 2 taken 40102 times.
✗ Branch 3 not taken.
47113 if((moveflags & move_obeys_grav) && isSideViewGravity())
721 return false;
722 47113 }
723
724
2/4
✓ Branch 0 taken 181035 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 181035 times.
181035 bool nosolid = !((moveflags & move_ignore_solidity) || (special==spw_wizzrobe) || (special==spw_floater));
725
726
3/4
✓ Branch 0 taken 87918 times.
✓ Branch 1 taken 93117 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 87918 times.
181035 if(dx && !dy)
727 {
728
2/2
✓ Branch 0 taken 41442 times.
✓ Branch 1 taken 46476 times.
87918 if(dx < 0)
729 {
730
2/4
✓ Branch 0 taken 41442 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 41442 times.
41442 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
731 41442 int mx = (bx+dx).getFloor();
732
2/2
✓ Branch 0 taken 80133 times.
✓ Branch 1 taken 23099 times.
103232 for(zfix ty = 0; by+ty < ry; ty += 8)
733 {
734
2/2
✓ Branch 0 taken 61790 times.
✓ Branch 1 taken 18343 times.
80133 if(scr_walkflag(mx, by+ty, special, left, mx, by, kb))
735 18343 return false;
736 61790 }
737
2/2
✓ Branch 0 taken 624 times.
✓ Branch 1 taken 22475 times.
23099 if(scr_walkflag(mx, ry, special, left, mx, by, kb))
738 624 return false;
739
4/4
✓ Branch 0 taken 18723 times.
✓ Branch 1 taken 3752 times.
✓ Branch 2 taken 18722 times.
✓ Branch 3 taken 1 times.
22475 if(nosolid && collide_object(bx+dx,by,-dx,hit_height,this))
740 1 return false;
741 22474 }
742 else
743 {
744 46476 int mx = (rx+dx).getCeil();
745 46476 int lx = mx-hit_width+1;
746
2/2
✓ Branch 0 taken 79733 times.
✓ Branch 1 taken 23855 times.
103588 for(zfix ty = 0; by+ty < ry; ty += 8)
747 {
748
2/2
✓ Branch 0 taken 57112 times.
✓ Branch 1 taken 22621 times.
79733 if(scr_walkflag(mx, by+ty, special, right, lx, by, kb))
749 22621 return false;
750 57112 }
751
2/2
✓ Branch 0 taken 209 times.
✓ Branch 1 taken 23646 times.
23855 if(scr_walkflag(mx, ry, special, right, lx, by, kb))
752 209 return false;
753
3/4
✓ Branch 0 taken 20207 times.
✓ Branch 1 taken 3439 times.
✓ Branch 2 taken 20207 times.
✗ Branch 3 not taken.
23646 if(nosolid && collide_object(bx+hit_width,by,dx,hit_height,this))
754 return false;
755 }
756 46120 }
757
2/4
✓ Branch 0 taken 93117 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 93117 times.
93117 else if(dy && !dx)
758 {
759
2/2
✓ Branch 0 taken 48384 times.
✓ Branch 1 taken 44733 times.
93117 if(dy < 0)
760 {
761
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48384 times.
48384 special = (special==spw_clipbottomright)?spw_none:special;
762 48384 int my = (by+dy).getFloor();
763
2/2
✓ Branch 0 taken 76133 times.
✓ Branch 1 taken 23042 times.
99175 for(zfix tx = 0; bx+tx < rx; tx += 8)
764 {
765
2/2
✓ Branch 0 taken 50791 times.
✓ Branch 1 taken 25342 times.
76133 if(scr_walkflag(bx+tx, my, special, up, bx, my, kb))
766 25342 return false;
767 50791 }
768
2/2
✓ Branch 0 taken 283 times.
✓ Branch 1 taken 22759 times.
23042 if(scr_walkflag(rx, my, special, up, bx, my, kb))
769 283 return false;
770
3/4
✓ Branch 0 taken 19000 times.
✓ Branch 1 taken 3759 times.
✓ Branch 2 taken 19000 times.
✗ Branch 3 not taken.
22759 if(nosolid && collide_object(bx,by+dy,hit_width,-dy,this))
771 return false;
772 22759 }
773 else
774 {
775 44733 int my = (ry+dy).getCeil();
776 44733 int ly = my-hit_height+1;
777
2/2
✓ Branch 0 taken 69864 times.
✓ Branch 1 taken 20923 times.
90787 for(zfix tx = 0; bx+tx < rx; tx += 8)
778 {
779
2/2
✓ Branch 0 taken 46054 times.
✓ Branch 1 taken 23810 times.
69864 if(scr_walkflag(bx+tx, my, special, down, bx, ly, kb))
780 23810 return false;
781 46054 }
782
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 20896 times.
20923 if(scr_walkflag(rx, my, special, down, bx, ly, kb))
783 27 return false;
784
3/4
✓ Branch 0 taken 17493 times.
✓ Branch 1 taken 3403 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17493 times.
20896 if(nosolid && collide_object(bx,by+hit_height,hit_width,dy,this))
785 return false;
786 }
787 43655 }
788 else //! Untested, and currently unused.
789 {
790 return scr_canmove(dx, 0, special, kb, ign_sv) && scr_canmove(dy, 0, special, kb, ign_sv);
791 }
792 89775 return true;
793 181035 }
794
795 bool enemy::scr_canplace(zfix dx, zfix dy, int32_t special, bool kb)
796 {
797 zfix bx = dx+hxofs, by = dy+hyofs; //left/top
798 zfix rx = bx+hit_width-1, ry = by+hit_height-1; //right/bottom
799
800 bool nosolid = !((moveflags & move_ignore_solidity) || (special==spw_wizzrobe) || (special==spw_floater));
801
802 if(nosolid && collide_object(bx,by,hit_width,hit_height,this))
803 return false;
804 for(zfix ty = 0; by+ty < ry; ty += 8)
805 {
806 for(zfix tx = 0; bx+tx < rx; tx += 8)
807 {
808 if(scr_walkflag(bx+tx, by+ty, special, -1, -1000, -1000, kb))
809 return false;
810 }
811 if(scr_walkflag(rx, by+ty, special, -1, -1000, -1000, kb))
812 return false;
813 }
814 for(zfix tx = 0; bx+tx < rx; tx += 8)
815 {
816 if(scr_walkflag(bx+tx, ry, special, -1, -1000, -1000, kb))
817 return false;
818 }
819 if(scr_walkflag(rx, ry, special, -1, -1000, -1000, kb))
820 return false;
821 return true;
822 }
823
824 bool enemy::scr_canplace(zfix dx, zfix dy, int32_t special, bool kb, int32_t nwid, int32_t nhei)
825 {
826 auto oxsz = hit_width, oysz = hit_height;
827 if(nwid > -1) hit_width = nwid;
828 if(nhei > -1) hit_height = nhei;
829 bool ret = scr_canplace(dx,dy,special,kb);
830 hit_width = oxsz; hit_height = oysz;
831 return ret;
832 }
833
834 113155 bool enemy::movexy(zfix dx, zfix dy, int32_t special, bool kb, bool ign_sv, bool earlyret)
835 {
836 113155 bool ret = true;
837
7/8
✓ Branch 0 taken 112634 times.
✓ Branch 1 taken 521 times.
✓ Branch 2 taken 32008 times.
✓ Branch 3 taken 80626 times.
✓ Branch 4 taken 28103 times.
✓ Branch 5 taken 3905 times.
✓ Branch 6 taken 28103 times.
✗ Branch 7 not taken.
113155 if(!ign_sv && dy < 0 && (moveflags & move_obeys_grav) && isSideViewGravity())
838 dy = 0;
839 113155 const int scl = 2;
840
4/4
✓ Branch 0 taken 15916 times.
✓ Branch 1 taken 125286 times.
✓ Branch 2 taken 28765 times.
✓ Branch 3 taken 112437 times.
141202 while(abs(dx) > scl || abs(dy) > scl)
841 {
842
2/2
✓ Branch 0 taken 14871 times.
✓ Branch 1 taken 13894 times.
28765 if(abs(dx) > abs(dy))
843 {
844 14871 int32_t tdx = dx.sign() * scl;
845
2/2
✓ Branch 0 taken 14099 times.
✓ Branch 1 taken 772 times.
14871 if(movexy(tdx, 0, special, kb, ign_sv, earlyret))
846 14099 dx -= tdx;
847 else
848 {
849
2/2
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 387 times.
772 if(earlyret) return false;
850 385 dx = tdx;
851 385 ret = false;
852 }
853 14484 }
854 else
855 {
856 13894 int32_t tdy = dy.sign() * scl;
857
2/2
✓ Branch 0 taken 13168 times.
✓ Branch 1 taken 726 times.
13894 if(movexy(0, tdy, special, kb, ign_sv, earlyret))
858 13168 dy -= tdy;
859 else
860 {
861
2/2
✓ Branch 0 taken 395 times.
✓ Branch 1 taken 331 times.
726 if(earlyret) return false;
862 395 dy = tdy;
863 395 ret = false;
864 }
865 }
866 }
867
868
2/2
✓ Branch 0 taken 48813 times.
✓ Branch 1 taken 63624 times.
112437 if(dx)
869 {
870
2/2
✓ Branch 0 taken 45302 times.
✓ Branch 1 taken 18322 times.
63624 if(scr_canmove(dx, 0, special, kb, ign_sv))
871 45302 x += dx;
872 else
873 {
874
2/2
✓ Branch 0 taken 16759 times.
✓ Branch 1 taken 1563 times.
18322 if(earlyret) return false;
875 1563 ret = false;
876 1563 int xsign = dx.sign();
877
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 1563 times.
1587 while(scr_canmove(xsign, 0, special, kb, ign_sv))
878 {
879 24 x += xsign;
880 24 dx -= xsign;
881 }
882
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1563 times.
1563 if(dx)
883 {
884 1563 dx.doDecBound(0,-9999, 0,9999);
885
3/6
✓ Branch 0 taken 1563 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1563 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1563 times.
✗ Branch 5 not taken.
24270 dx = binary_search_zfix(dx.decsign(), dx, [&](zfix val, zfix& retval){
886
2/2
✓ Branch 0 taken 794 times.
✓ Branch 1 taken 21913 times.
22707 if(scr_canmove(val, 0, special, kb, ign_sv))
887 {
888 794 retval = val;
889 794 return BSEARCH_CONTINUE_AWAY0;
890 }
891 21913 else return BSEARCH_CONTINUE_TOWARD0;
892 22707 });
893 1563 x += dx;
894 1563 }
895 }
896 46865 }
897
2/2
✓ Branch 0 taken 33883 times.
✓ Branch 1 taken 61795 times.
95678 if(dy)
898 {
899
2/2
✓ Branch 0 taken 42811 times.
✓ Branch 1 taken 18984 times.
61795 if(scr_canmove(0, dy, special, kb, ign_sv))
900 42811 y += dy;
901 else
902 {
903
2/2
✓ Branch 0 taken 16954 times.
✓ Branch 1 taken 2030 times.
18984 if(earlyret) return false;
904 2030 ret = false;
905 2030 int ysign = dy.sign();
906
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 2030 times.
2058 while(scr_canmove(0, ysign, special, kb, ign_sv))
907 {
908 28 y += ysign;
909 28 dy -= ysign;
910 }
911
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2030 times.
2030 if(dy)
912 {
913 2030 dy.doDecBound(0,-9999, 0,9999);
914
3/6
✓ Branch 0 taken 2030 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2030 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2030 times.
✗ Branch 5 not taken.
31294 dy = binary_search_zfix(dy.decsign(), dy, [&](zfix val, zfix& retval){
915
2/2
✓ Branch 0 taken 816 times.
✓ Branch 1 taken 28448 times.
29264 if(scr_canmove(0, val, special, kb, ign_sv))
916 {
917 816 retval = val;
918 816 return BSEARCH_CONTINUE_AWAY0;
919 }
920 28448 else return BSEARCH_CONTINUE_TOWARD0;
921 29264 });
922 2030 y += dy;
923 2030 }
924 }
925 44841 }
926 78724 return ret;
927 113155 }
928
929 51123 bool enemy::moveDir(int32_t dir, zfix px, int32_t special, bool kb, bool earlyret)
930 {
931
4/6
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 51115 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
51123 static const zfix diagrate = zslongToFix(7071);
932
7/13
✓ Branch 0 taken 51123 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 51123 times.
✓ Branch 4 taken 13029 times.
✓ Branch 5 taken 11932 times.
✓ Branch 6 taken 13226 times.
✓ Branch 7 taken 12792 times.
✓ Branch 8 taken 144 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
51123 switch(NORMAL_DIR(dir))
933 {
934 case up:
935 13029 return movexy(0, -px, special, kb, false, earlyret);
936 case down:
937 11932 return movexy(0, px, special, kb, false, earlyret);
938 case left:
939 13226 return movexy(-px, 0, special, kb, false, earlyret);
940 case right:
941 12792 return movexy(px, 0, special, kb, false, earlyret);
942 case r_up:
943 144 return movexy(px*diagrate, -px*diagrate, special, kb, false, earlyret);
944 case r_down:
945 return movexy(px*diagrate, px*diagrate, special, kb, false, earlyret);
946 case l_up:
947 return movexy(-px*diagrate, -px*diagrate, special, kb, false, earlyret);
948 case l_down:
949 return movexy(-px*diagrate, px*diagrate, special, kb, false, earlyret);
950 }
951 return false;
952 51123 }
953
954 9517 bool enemy::moveAtAngle(zfix degrees, zfix px, int32_t special, bool kb, bool earlyret)
955 {
956 9517 double v = degrees.getFloat() * PI / 180.0;
957 9517 zfix dx = zc::math::Cos(v)*px, dy = zc::math::Sin(v)*px;
958 9517 return movexy(dx, dy, special, kb, false, earlyret);
959 }
960
961 bool enemy::can_movexy(zfix dx, zfix dy, int32_t special, bool kb)
962 {
963 zfix tx = x, ty = y;
964 bool ret = movexy(dx, dy, special, kb, false, true);
965 x = tx;
966 y = ty;
967 return ret;
968 }
969 39290 bool enemy::can_moveDir(int32_t dir, zfix px, int32_t special, bool kb)
970 {
971 39290 zfix tx = x, ty = y;
972 39290 bool ret = moveDir(dir, px, special, kb, true);
973 39290 x = tx;
974 39290 y = ty;
975 39290 return ret;
976 }
977 bool enemy::can_moveAtAngle(zfix degrees, zfix px, int32_t special, bool kb)
978 {
979 zfix tx = x, ty = y;
980 bool ret = moveAtAngle(degrees, px, special, kb, true);
981 x = tx;
982 y = ty;
983 return ret;
984 }
985
986 // Handle pitfalls
987 39027235 bool enemy::do_falling(int32_t index)
988 {
989
2/2
✓ Branch 0 taken 39024016 times.
✓ Branch 1 taken 3219 times.
39027235 if(fallclk > 0)
990 {
991
4/4
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 3173 times.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 32 times.
3219 if(fallclk == PITFALL_FALL_FRAMES && fallCombo) sfx(combobuf[fallCombo].attribytes[0], pan(x));
992
2/2
✓ Branch 0 taken 3173 times.
✓ Branch 1 taken 46 times.
3219 if(!--fallclk)
993 {
994
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46 times.
46 if(immortal) //Keep alive forever
995 ++fallclk; //force another frame of falling.... forever.
996
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 23 times.
46 else if(dying) //Give 1 frame for script revival
997 {
998
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(flags&guy_never_return)
999 never_return(screen_spawned, index);
1000
1001
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(leader)
1002 kill_em_all();
1003
1004 //leave_item(); //Don't drop items in pits!
1005 23 stop_bgsfx(index);
1006 23 return true;
1007 }
1008 else
1009 {
1010 23 try_death(true); //Force death
1011 23 ++fallclk; //force another frame of falling
1012 }
1013 23 }
1014
1015 3196 wpndata& spr = wpnsbuf[QMisc.sprites[sprFALL]];
1016 3196 cs = spr.csets & 0xF;
1017
1/2
✓ Branch 0 taken 3196 times.
✗ Branch 1 not taken.
3196 int32_t fr = spr.frames ? spr.frames : 1;
1018
1/2
✓ Branch 0 taken 3196 times.
✗ Branch 1 not taken.
3196 int32_t spd = spr.speed ? spr.speed : 1;
1019 3196 int32_t animclk = (PITFALL_FALL_FRAMES-fallclk);
1020
2/2
✓ Branch 0 taken 1496 times.
✓ Branch 1 taken 1700 times.
3196 tile = spr.tile + zc_min(animclk / spd, fr-1);
1021 3196 }
1022 39027212 return false;
1023 39027235 }
1024
1025 // Handle drowning in water
1026 39024016 bool enemy::do_drowning(int32_t index)
1027 {
1028
2/2
✓ Branch 0 taken 39022607 times.
✓ Branch 1 taken 1409 times.
39024016 if(drownclk > 0)
1029 {
1030 //if(drownclk == WATER_DROWN_FRAMES && drownCombo) sfx(combobuf[drownCombo].attribytes[0], pan(x));
1031 //!TODO: Drown SFX
1032
2/2
✓ Branch 0 taken 1367 times.
✓ Branch 1 taken 42 times.
1409 if(!--drownclk)
1033 {
1034
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(immortal) //Keep alive forever
1035 ++drownclk; //force another frame of falling.... forever.
1036
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 21 times.
42 else if(dying) //Give 1 frame for script revival
1037 {
1038
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 if(flags&guy_never_return)
1039 never_return(screen_spawned, index);
1040
1041
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 if(leader)
1042 kill_em_all();
1043
1044 //leave_item(); //Don't drop items in pits!
1045 21 stop_bgsfx(index);
1046 21 return true;
1047 }
1048 else
1049 {
1050 21 try_death(true); //Force death
1051 21 ++drownclk; //force another frame of falling
1052 }
1053 21 }
1054
1055
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1388 times.
1388 bool lava = (drownCombo && combobuf[drownCombo].usrflags&cflag1);
1056 1388 wpndata &spr = wpnsbuf[QMisc.sprites[lava ? sprLAVADROWN : sprDROWN]];
1057 1388 cs = spr.csets & 0xF;
1058
1/2
✓ Branch 0 taken 1388 times.
✗ Branch 1 not taken.
1388 int32_t fr = spr.frames ? spr.frames : 1;
1059
1/2
✓ Branch 0 taken 1388 times.
✗ Branch 1 not taken.
1388 int32_t spd = spr.speed ? spr.speed : 1;
1060 1388 int32_t animclk = (WATER_DROWN_FRAMES-drownclk);
1061
2/2
✓ Branch 0 taken 1177 times.
✓ Branch 1 taken 211 times.
1388 tile = spr.tile + zc_min((animclk % (spd*fr))/spd, fr-1);
1062 1388 }
1063 39023995 return false;
1064 39024016 }
1065
1066 // Supplemental animation code that all derived classes should call
1067 // as a return value for animate().
1068 // Handles the death animation and returns true when enemy is finished.
1069 39714025 bool enemy::Dead(int32_t index)
1070 {
1071
2/2
✓ Branch 0 taken 29981 times.
✓ Branch 1 taken 39684044 times.
39714025 if(immortal)
1072 {
1073 29981 dying = false;
1074 29981 return false;
1075 }
1076
2/2
✓ Branch 0 taken 794520 times.
✓ Branch 1 taken 38889524 times.
39684044 if(dying)
1077 {
1078
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 794519 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
794520 if(deathexstate > -1 && deathexstate < 32)
1079 {
1080 1 setxmapflag(screen_spawned, 1<<deathexstate);
1081 1 deathexstate = -1;
1082 1 }
1083 794520 --clk2;
1084
1085
4/4
✓ Branch 0 taken 725657 times.
✓ Branch 1 taken 68863 times.
✓ Branch 2 taken 38736 times.
✓ Branch 3 taken 3242 times.
794520 if((get_qr(qr_HARDCODED_ENEMY_ANIMS) && clk2==12)
1086
2/2
✓ Branch 0 taken 41978 times.
✓ Branch 1 taken 683679 times.
725657 && hp>-1000) // not killed by ringleader
1087 38736 death_sfx();
1088
1089
2/2
✓ Branch 0 taken 749620 times.
✓ Branch 1 taken 44900 times.
794520 if(clk2==0)
1090 {
1091
2/2
✓ Branch 0 taken 44196 times.
✓ Branch 1 taken 704 times.
44900 if(flags&guy_never_return)
1092 704 never_return(screen_spawned, index);
1093
1094
2/2
✓ Branch 0 taken 44822 times.
✓ Branch 1 taken 78 times.
44900 if(leader)
1095 78 kill_em_all();
1096
1097 44900 leave_item();
1098 44900 }
1099
1100 794520 stop_bgsfx(index);
1101 794520 return (clk2==0);
1102 }
1103
1104 38889524 return false;
1105 39714025 }
1106
1107 // Basic animation code that all derived classes should call.
1108 // The one with an index is the one that is called by
1109 // the guys sprite list; index is the enemy's index in the list.
1110 39027491 bool enemy::animate(int32_t index)
1111 {
1112 39027491 update_current_screen();
1113
2/2
✓ Branch 0 taken 1785810 times.
✓ Branch 1 taken 37241681 times.
39027491 if(sclk <= 0) hitdir = -1;
1114
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 39027235 times.
39027491 if(switch_hooked)
1115 {
1116
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(get_qr(qr_SWITCHOBJ_RUN_SCRIPT))
1117 {
1118 //Run its script
1119 if (!didScriptThisFrame)
1120 {
1121 if (runscript_do_earlyret(run_script(MODE_NORMAL)))
1122 {
1123 return 0; //Avoid NULLPO if this object deleted itself
1124 }
1125 }
1126 }
1127 256 return false;
1128 }
1129
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 39027212 times.
39027235 if(do_falling(index)) return true;
1130
2/2
✓ Branch 0 taken 3196 times.
✓ Branch 1 taken 39024016 times.
39027212 else if(fallclk)
1131 {
1132 //clks
1133
2/2
✓ Branch 0 taken 2275 times.
✓ Branch 1 taken 921 times.
3196 if(hclk>0)
1134 921 --hclk;
1135
1/2
✓ Branch 0 taken 3196 times.
✗ Branch 1 not taken.
3196 if(stunclk>0)
1136 --stunclk;
1137
1/2
✓ Branch 0 taken 3196 times.
✗ Branch 1 not taken.
3196 if ( frozenclock > 0 )
1138 --frozenclock;
1139
1/2
✓ Branch 0 taken 3196 times.
✗ Branch 1 not taken.
3196 if(hashero)
1140 {
1141 Hero.setX(x);
1142 Hero.setY(y);
1143 Hero.fallCombo = fallCombo;
1144 Hero.fallclk = fallclk;
1145
1146 if(hashero)
1147 {
1148 hashero = false; //Let Hero go if falling
1149 Hero.setEaten(0);
1150 }
1151 }
1152
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3196 times.
3196 if (!didScriptThisFrame)
1153 {
1154 3196 run_script(MODE_NORMAL);
1155 3196 }
1156 3196 return false;
1157 }
1158
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 39023995 times.
39024016 if(do_drowning(index)) return true;
1159
2/2
✓ Branch 0 taken 1388 times.
✓ Branch 1 taken 39022607 times.
39023995 else if(drownclk)
1160 {
1161 //clks
1162
2/2
✓ Branch 0 taken 853 times.
✓ Branch 1 taken 535 times.
1388 if(hclk>0)
1163 535 --hclk;
1164
1/2
✓ Branch 0 taken 1388 times.
✗ Branch 1 not taken.
1388 if(stunclk>0)
1165 --stunclk;
1166
1/2
✓ Branch 0 taken 1388 times.
✗ Branch 1 not taken.
1388 if ( frozenclock > 0 )
1167 --frozenclock;
1168
1/2
✓ Branch 0 taken 1388 times.
✗ Branch 1 not taken.
1388 if(hashero)
1169 {
1170 Hero.setX(x);
1171 Hero.setY(y);
1172 Hero.drownclk = drownclk;
1173
1174 if(hashero)
1175 {
1176 hashero = false; //Let Hero go if falling
1177 Hero.setEaten(0);
1178 }
1179 }
1180
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1388 times.
1388 if (!didScriptThisFrame)
1181 {
1182 1388 run_script(MODE_NORMAL);
1183 1388 }
1184 1388 return false;
1185 }
1186 39022607 int32_t nx = real_x(x);
1187 39022607 int32_t ny = real_y(y);
1188
1189
4/4
✓ Branch 0 taken 28201979 times.
✓ Branch 1 taken 10820628 times.
✓ Branch 2 taken 5865377 times.
✓ Branch 3 taken 22336602 times.
39022607 if(ox!=nx || oy!=ny)
1190 {
1191 16686005 posframe=(posframe+1)%(get_qr(qr_NEWENEMYTILES)?4:2);
1192 16686005 }
1193
1194 39022607 ox = nx;
1195 39022607 oy = ny;
1196
1197 // Maybe they fell off the bottom in sideview, or were moved by a script.
1198
1199 //Check offscreen settings. I wrote it this way for clarity and to simplify testing. -Z
1200
2/2
✓ Branch 0 taken 29986 times.
✓ Branch 1 taken 38992621 times.
39022607 if ( immortal )
1201 {
1202 //skip, as it can go out of bounds, from immortality
1203 29986 }
1204
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 38992621 times.
✓ Branch 2 taken 38992621 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 38992621 times.
38992621 else if ( (moveflags & move_ignore_screenedge) || (( (get_qr(qr_OUTOFBOUNDSENEMIES)) != bool(editorflags&ENEMY_FLAG11) ) && !NEWOUTOFBOUNDS(x,y,z+fakez)) )
1205 {
1206 //skip, it can go out of bounds, from a quest rule, or from the enemy editor (but not both!)
1207 }
1208
2/2
✓ Branch 0 taken 38961005 times.
✓ Branch 1 taken 31616 times.
38992621 else if (OUTOFBOUNDS(id, x, y))
1209 {
1210 31616 hp=-1000; //kill it, as it is not immortal, and no quest bit or rule is enabled
1211 31616 }
1212 //fall down
1213 39022607 handle_termv();
1214
6/6
✓ Branch 0 taken 27570660 times.
✓ Branch 1 taken 11451947 times.
✓ Branch 2 taken 11181564 times.
✓ Branch 3 taken 27841043 times.
✓ Branch 4 taken 518775 times.
✓ Branch 5 taken 10662789 times.
39022607 if((enemycanfall(id) || (moveflags & move_obeys_grav) )&& fading != fade_flicker && clk>=0)
1215 {
1216
2/2
✓ Branch 0 taken 387698 times.
✓ Branch 1 taken 10275091 times.
10662789 if(isSideViewGravity())
1217 {
1218
1/2
✓ Branch 0 taken 387698 times.
✗ Branch 1 not taken.
387698 if(get_qr(qr_OLD_SIDEVIEW_LANDING_CODE))
1219 {
1220
2/2
✓ Branch 0 taken 230320 times.
✓ Branch 1 taken 157378 times.
387698 if(!isOnSideviewPlatform())
1221 {
1222 157378 bool willHitSVPlatform = false;
1223
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 157378 times.
157378 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH)?hit_width:16;
1224
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 157378 times.
157378 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT)?hit_height:16;
1225
2/2
✓ Branch 0 taken 157378 times.
✓ Branch 1 taken 157378 times.
314756 for(int32_t nx = x+4; nx < x+usewid; nx+=16)
1226 {
1227
5/8
✓ Branch 0 taken 23519 times.
✓ Branch 1 taken 133859 times.
✓ Branch 2 taken 23519 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23519 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 157378 times.
✗ Branch 7 not taken.
157378 if(fall > 0 && !IGNORE_SIDEVIEW_PLATFORMS && checkSVLadderPlatform(x+4,y+(fall/100)+usehei-1) && (((int32_t(y)+(int32_t(fall)/100)+usehei-1)&0xF0)!=((int32_t(y)+usehei-1)&0xF0)))
1228 {
1229 willHitSVPlatform = true;
1230 break;
1231 }
1232 157378 }
1233
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 157378 times.
157378 if(willHitSVPlatform)
1234 {
1235 y+=fall/100;
1236 //y-=int32_t(y)%16; //Fix to top of SV Ladder
1237 do_fix(y, 16); //Fix to top of SV Ladder
1238 fall = 0;
1239 }
1240 else
1241 {
1242 157378 y+=fall/100;
1243
2/2
✓ Branch 0 taken 17812 times.
✓ Branch 1 taken 139566 times.
157378 if(fall <= get_terminalv_fall())
1244 139566 fall += get_grav_fall();
1245 }
1246 157378 }
1247 else
1248 {
1249
2/2
✓ Branch 0 taken 277 times.
✓ Branch 1 taken 230043 times.
230320 if(fall!=0) // Only fix pos once
1250 {
1251 //y-=(int32_t)y%8; // Fix position
1252 277 do_fix(y, 8); //Fix position
1253 277 }
1254
1255 230320 fall = 0;
1256 }
1257 387698 }
1258 else
1259 {
1260 if(isOnSideviewPlatform())
1261 fall = 0;
1262 else
1263 {
1264 zfix fall_amnt = fall/100;
1265 bool hit = false;
1266 while(fall_amnt >= 1)
1267 {
1268 --fall_amnt;
1269 ++y;
1270 if(isOnSideviewPlatform())
1271 {
1272 y = y.getInt();
1273 fall_amnt = 0;
1274 hit = true;
1275 break;
1276 }
1277 }
1278 if(fall_amnt > 0)
1279 y += fall_amnt;
1280 if(fall_amnt < 0)
1281 {
1282 if(!movexy(0,fall_amnt,spw_none,false,!get_qr(qr_BROKEN_SIDEVIEW_SPRITE_JUMP)))
1283 hit = true;
1284 }
1285 if(hit)
1286 fall = 0;
1287 else if(fall <= get_terminalv_fall())
1288 fall += get_grav_fall();
1289 }
1290 }
1291 387698 }
1292 else
1293 {
1294
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10275091 times.
10275091 if (!(moveflags & move_no_fake_z))
1295 {
1296
2/2
✓ Branch 0 taken 5707028 times.
✓ Branch 1 taken 4568063 times.
10275091 if(fakefall!=0)
1297 4568063 fakez-=(fakefall/100);
1298
1299
2/2
✓ Branch 0 taken 4568063 times.
✓ Branch 1 taken 5707028 times.
10275091 if(fakez<0)
1300 4568063 fakez = fakefall = 0;
1301
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5707028 times.
5707028 else if(fakefall <= get_terminalv_fall())
1302 5707028 fakefall += get_grav_fall();
1303
1304
5/6
✓ Branch 0 taken 10275091 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5707028 times.
✓ Branch 3 taken 4568063 times.
✓ Branch 4 taken 4582310 times.
✓ Branch 5 taken 1124718 times.
10275091 if (fakez<=0 && fakefall > 0 && !get_qr(qr_FLUCTUATING_ENEMY_JUMP)) fakefall = 0;
1305 10275091 }
1306
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10275091 times.
10275091 if (!(moveflags & move_no_real_z))
1307 {
1308
2/2
✓ Branch 0 taken 6129417 times.
✓ Branch 1 taken 4145674 times.
10275091 if(fall!=0)
1309 4145674 z-=(fall/100);
1310
1311
2/2
✓ Branch 0 taken 4120761 times.
✓ Branch 1 taken 6154330 times.
10275091 if(z<0)
1312 4120761 z = fall = 0;
1313
2/2
✓ Branch 0 taken 16075 times.
✓ Branch 1 taken 6138255 times.
6154330 else if(fall <= get_terminalv_fall())
1314 6138255 fall += get_grav_fall();
1315
1316
6/6
✓ Branch 0 taken 10222435 times.
✓ Branch 1 taken 52656 times.
✓ Branch 2 taken 6101674 times.
✓ Branch 3 taken 4120761 times.
✓ Branch 4 taken 4990689 times.
✓ Branch 5 taken 1110985 times.
10275091 if (z<=0 && fall > 0 && !get_qr(qr_FLUCTUATING_ENEMY_JUMP)) fall = 0;
1317 10275091 }
1318
1319 }
1320 10662789 }
1321 39022607 handle_termv();
1322
10/10
✓ Branch 0 taken 30760564 times.
✓ Branch 1 taken 8262043 times.
✓ Branch 2 taken 29433125 times.
✓ Branch 3 taken 1327439 times.
✓ Branch 4 taken 29294316 times.
✓ Branch 5 taken 138809 times.
✓ Branch 6 taken 4329044 times.
✓ Branch 7 taken 26431520 times.
✓ Branch 8 taken 19103256 times.
✓ Branch 9 taken 23432300 times.
39022607 if (can_pitfall() && ((z <= 0 && fakez <= 0 && !isflier(id)) || (isflier(id) && (stunclk))) && !superman)
1323 {
1324
4/4
✓ Branch 0 taken 23016776 times.
✓ Branch 1 taken 415524 times.
✓ Branch 2 taken 13153465 times.
✓ Branch 3 taken 9863311 times.
23432300 if (!isSideViewGravity() && (moveflags & move_can_pitfall))
1325 9863311 fallCombo = check_pits();
1326
4/4
✓ Branch 0 taken 415524 times.
✓ Branch 1 taken 23016776 times.
✓ Branch 2 taken 659954 times.
✓ Branch 3 taken 22356822 times.
23432300 if (!(isSideViewGravity() && get_qr(qr_OLD_SPRITE_FALL_DROWN)) && (moveflags & move_can_waterdrown))
1327 659954 drownCombo = check_water();
1328 23432300 }
1329
1330 77229119 runKnockback(); //scripted knockback handling
1331
1332 // clk is incremented here
1333
2/2
✓ Branch 0 taken 74869461 times.
✓ Branch 1 taken 2359658 times.
77229119 if(++clk >= frate)
1334 2359658 clk=0;
1335
1336 // hit and death handling
1337
2/2
✓ Branch 0 taken 1324357 times.
✓ Branch 1 taken 75904762 times.
77229119 if(hclk>0)
1338 1324357 --hclk;
1339
1340
2/2
✓ Branch 0 taken 684748 times.
✓ Branch 1 taken 76544371 times.
77229119 if(stunclk>0)
1341 684748 --stunclk;
1342
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77229119 times.
77229119 if ( frozenclock > 0 )
1343 --frozenclock;
1344
1345
5/6
✓ Branch 0 taken 22710 times.
✓ Branch 1 taken 77206409 times.
✓ Branch 2 taken 189 times.
✓ Branch 3 taken 22521 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 189 times.
77229119 if(ceiling && z <= 0 && fakez <= 0)
1346 189 ceiling = false;
1347
1348 77229119 try_death();
1349
1350 77229119 scored=false;
1351
1352 77229119 ++c_clk;
1353
1354 //Run its script
1355
2/2
✓ Branch 0 taken 38252937 times.
✓ Branch 1 taken 38976182 times.
77229119 if (!didScriptThisFrame)
1356 {
1357
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 38976176 times.
38976182 if (runscript_do_earlyret(run_script(MODE_NORMAL)))
1358 {
1359 6 return 0; //Avoid NULLPO if this object deleted itself
1360 }
1361 38976176 }
1362
1363 // returns true when enemy is defeated
1364 77229113 return Dead(index);
1365 77234003 }
1366
1367 39799703 bool enemy::setSolid(bool set)
1368 {
1369
1/2
✓ Branch 0 taken 39799703 times.
✗ Branch 1 not taken.
39799703 bool actual = set && !isSubmerged();
1370 39799703 bool ret = solid_object::setSolid(actual);
1371 39799703 solid = set;
1372 39799703 return ret;
1373 }
1374 void enemy::doContactDamage(int32_t hdir)
1375 {
1376 Hero.hithero(guys.find(this), hdir);
1377 }
1378
1379 29704 void enemy::solid_push(solid_object *obj)
1380 {
1381
1/2
✓ Branch 0 taken 29704 times.
✗ Branch 1 not taken.
29704 if(obj == this) return; //can't push self
1382
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29704 times.
29704 if(moveflags&move_not_pushable) return; //not pushable
1383 29704 zfix dx, dy;
1384 29704 int32_t hdir = -1;
1385 29704 solid_push_int(obj,dx,dy,hdir,true);
1386
1387
4/4
✓ Branch 0 taken 29591 times.
✓ Branch 1 taken 113 times.
✓ Branch 2 taken 336 times.
✓ Branch 3 taken 29255 times.
29704 if(!dx && !dy) return;
1388
1389 449 bool t = obj->getTempNonsolid();
1390 449 obj->setTempNonsolid(true);
1391
1392 449 int32_t ydir = dy > 0 ? down : up;
1393 449 int32_t xdir = dx > 0 ? right : left;
1394
1395 449 auto special = isflier(id) ? spw_floater : spw_none;
1396
2/2
✓ Branch 0 taken 397 times.
✓ Branch 1 taken 52 times.
449 if(!movexy(dx,dy,special,true,true))
1397 {
1398 //Crushed?
1399 52 }
1400
1401 449 obj->setTempNonsolid(t);
1402 29704 }
1403 29704 bool enemy::is_unpushable() const
1404 {
1405 29704 return isSubmerged();
1406 }
1407 29163 bool enemy::sideview_mode() const
1408 {
1409
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29163 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
29163 return isSideViewGravity() && (moveflags&move_obeys_grav) && !(moveflags&move_not_pushable);
1410 }
1411
1412 3236 bool enemy::m_walkflag_old(int32_t dx,int32_t dy,int32_t special, int32_t x, int32_t y)
1413 {
1414 3236 int32_t yg = (special==spw_floater)?8:0;
1415 3236 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1416
1417
8/10
✓ Branch 0 taken 2366 times.
✓ Branch 1 taken 870 times.
✓ Branch 2 taken 814 times.
✓ Branch 3 taken 56 times.
✓ Branch 4 taken 870 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 870 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2370 times.
✓ Branch 9 taken 3240 times.
3236 if(dx<16-nb || dy<zc_max(16-yg-nb,0) || dx>=world_w-16+nb || dy>=world_h-16+nb)
1418 4736 return true;
1419
1420 3240 bool isInDungeon = isdungeon(screen_spawned);
1421
3/4
✓ Branch 0 taken 262 times.
✓ Branch 1 taken 2978 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 262 times.
3240 if(isInDungeon || special==spw_wizzrobe)
1422 {
1423
7/8
✓ Branch 0 taken 601 times.
✓ Branch 1 taken 2377 times.
✓ Branch 2 taken 595 times.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 604 times.
✓ Branch 5 taken 1779 times.
✓ Branch 6 taken 604 times.
✗ Branch 7 not taken.
2978 if((x>=32 && dy<32-yg) || (y>-1000 && y<=144 && dy>=144))
1424 1199 return true;
1425
1426
7/8
✓ Branch 0 taken 592 times.
✓ Branch 1 taken 1187 times.
✓ Branch 2 taken 595 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 595 times.
✓ Branch 5 taken 595 times.
✓ Branch 6 taken 595 times.
✗ Branch 7 not taken.
1779 if((x>=32 && dx<32) || (x>-1000 && x<224 && dx>=224))
1427
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
1190 if(special!=spw_door) // walk in door way
1428 return true;
1429 595 }
1430
1431
3/4
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 795 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
857 if(!(moveflags & move_can_pitwalk) && !(moveflags & move_can_pitfall)) //Don't walk into pits (knockback doesn't call this func)
1432 {
1433
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
124 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1434
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1435 return true;
1436 62 }
1437
1438
1/4
✓ Branch 0 taken 857 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
857 switch(special)
1439 {
1440 case spw_clipbottomright:
1441 if(dy>=128 || dx>=208) return true;
1442 break;
1443 case spw_clipright:
1444 break; //if(x>=208) return true; break;
1445
1446 case spw_wizzrobe: // fall through
1447 case spw_floater: // Special case for fliers and wizzrobes - hack!
1448 {
1449
2/2
✓ Branch 0 taken 262 times.
✓ Branch 1 taken 595 times.
857 if(isInDungeon)
1450 {
1451
2/4
✓ Branch 0 taken 595 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 595 times.
595 if(dy < 32-yg || dy >= 144) return true;
1452
2/4
✓ Branch 0 taken 595 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 595 times.
595 if(dx < 32 || dx >= 224) return true;
1453 595 }
1454 857 return false;
1455 }
1456 }
1457
1458 dx = CLEAR_LOW_BITS(dx, special == spw_halfstep ? 3 : 4);
1459 dy = CLEAR_LOW_BITS(dy, special == spw_halfstep || isSideViewGravity() ? 3 : 4);
1460
1461 if(special==spw_water)
1462 return (water_walkflag(dx,dy+8,1) || water_walkflag(dx+8,dy+8,1));
1463
1464 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1465 groundblocked(dx,dy+8) || groundblocked(dx+8,dy+8);
1466 870 }
1467
1468 6575 bool enemy::m_walkflag_simple(int32_t dx,int32_t dy)
1469 {
1470 6575 bool kb = false;
1471 6575 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1472
1473
5/10
✗ Branch 0 not taken.
✓ Branch 1 taken 6575 times.
✓ Branch 2 taken 6575 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6575 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6575 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 6575 times.
6575 if(dx<16-nb || dy<zc_max(16-nb,0) || dx>=world_w-16+nb || dy>=world_h-16+nb)
1474 return true;
1475
1476
2/2
✓ Branch 0 taken 5062 times.
✓ Branch 1 taken 1513 times.
6575 if(isdungeon(screen_spawned))
1477 {
1478
2/4
✓ Branch 0 taken 1513 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1513 times.
1513 if((dy<32) || (dy>=world_h-32))
1479 return true;
1480
1481
2/4
✓ Branch 0 taken 1513 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1513 times.
1513 if((dx<32) || (dx>=world_w-32))
1482 return true;
1483 1513 }
1484
1485
2/4
✓ Branch 0 taken 6575 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6575 times.
6575 if(!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall))) //Don't walk into pits, unless being knocked back
1486 {
1487
2/4
✓ Branch 0 taken 6575 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6575 times.
13150 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1488
2/4
✓ Branch 0 taken 6575 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6575 times.
✗ Branch 3 not taken.
6575 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1489 return true;
1490 6575 }
1491
1492
2/2
✓ Branch 0 taken 6545 times.
✓ Branch 1 taken 30 times.
6575 if(get_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY))
1493 {
1494
3/4
✓ Branch 0 taken 2657 times.
✓ Branch 1 taken 3888 times.
✓ Branch 2 taken 2657 times.
✗ Branch 3 not taken.
9202 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1495
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2657 times.
2657 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1496 }
1497 else
1498 {
1499
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
60 return _walkflag(dx,dy,1) || _walkflag(dx+8,dy,1) ||
1500
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1501
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 groundblocked(dx,dy,kb) || groundblocked(dx+8,dy,kb) ||
1502
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1503 }
1504 6575 }
1505
1506 // returns true if cannot walk
1507 32942792 bool enemy::m_walkflag(int32_t dx,int32_t dy,int32_t special, int32_t dir, int32_t input_x, int32_t input_y, bool kb)
1508 {
1509
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32942792 times.
32942792 if(moveflags & move_new_movement)
1510 return scr_walkflag(dx,dy,special,dir,input_x,input_y,kb);
1511 32942792 int32_t yg = (special==spw_floater)?8:0;
1512 32942792 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1513
2/2
✓ Branch 0 taken 3888710 times.
✓ Branch 1 taken 29054082 times.
32942792 switch(dir)
1514 {
1515 case l_down:
1516 case r_down:
1517 case down:
1518 case 11: //r_down
1519 case 12: //down
1520 case 13: //l_down
1521 {
1522
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3888710 times.
3888710 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
1523 {
1524
3/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 3888702 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
3888710 if ( SIZEflags&OVERRIDE_HIT_HEIGHT && !isflier(id) )
1525 {
1526 //Small enemies are treated as 16x16, for the purposes of m_walkflag!
1527
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 dy += zc_max(hit_height-16,0);
1528 8 }
1529 3888710 }
1530 3888710 break;
1531 }
1532 }
1533
2/2
✓ Branch 0 taken 3876995 times.
✓ Branch 1 taken 29065797 times.
32942792 switch(dir)
1534 {
1535 case r_up:
1536 case r_down:
1537 case right:
1538 case 9: //r_up
1539 case 10: //right
1540 case 11: //r_down
1541 {
1542
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3876995 times.
3876995 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
1543 {
1544
3/4
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 3876950 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 45 times.
3876995 if ( SIZEflags&OVERRIDE_HIT_WIDTH && !isflier(id) )
1545 {
1546 //Small enemies are treated as 16x16, for the purposes of m_walkflag!
1547
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 dx += zc_max(hit_width-16,0);
1548 45 }
1549 3876995 }
1550 3876995 break;
1551 }
1552 }
1553
1554
10/10
✓ Branch 0 taken 22398333 times.
✓ Branch 1 taken 10544459 times.
✓ Branch 2 taken 8940039 times.
✓ Branch 3 taken 1604420 times.
✓ Branch 4 taken 10505543 times.
✓ Branch 5 taken 38916 times.
✓ Branch 6 taken 10481553 times.
✓ Branch 7 taken 23990 times.
✓ Branch 8 taken 22453602 times.
✓ Branch 9 taken 32935155 times.
32942792 if(dx<16-nb || dy<zc_max(16-yg-nb,0) || dx>=world_w-16+nb || dy>=world_h-16+nb)
1555 44914841 return true;
1556
1557 32935155 bool isInDungeon = isdungeon(screen_spawned);
1558
4/4
✓ Branch 0 taken 4413396 times.
✓ Branch 1 taken 28521759 times.
✓ Branch 2 taken 11756 times.
✓ Branch 3 taken 4401640 times.
32935155 if(isInDungeon || special==spw_wizzrobe)
1559 {
1560
8/8
✓ Branch 0 taken 5892236 times.
✓ Branch 1 taken 22641279 times.
✓ Branch 2 taken 5667745 times.
✓ Branch 3 taken 224491 times.
✓ Branch 4 taken 5820349 times.
✓ Branch 5 taken 17045421 times.
✓ Branch 6 taken 5820162 times.
✓ Branch 7 taken 187 times.
28533515 if((input_x>=32 && dy<32-yg) || (input_y>-1000 && input_y<=world_h-32 && dy>=world_h-32))
1561 11487907 return true;
1562
1563
8/8
✓ Branch 0 taken 5739852 times.
✓ Branch 1 taken 11305756 times.
✓ Branch 2 taken 5573332 times.
✓ Branch 3 taken 166520 times.
✓ Branch 4 taken 5688285 times.
✓ Branch 5 taken 5783991 times.
✓ Branch 6 taken 5687331 times.
✓ Branch 7 taken 954 times.
17045608 if((input_x>=32 && dx<32) || (input_x>-1000 && input_x<world_w-32 && dx>=world_w-32))
1564
2/2
✓ Branch 0 taken 113905 times.
✓ Branch 1 taken 94 times.
11260663 if(special!=spw_door) // walk in door way
1565 113905 return true;
1566 5785039 }
1567
1568
6/6
✓ Branch 0 taken 3260136 times.
✓ Branch 1 taken 6926543 times.
✓ Branch 2 taken 907960 times.
✓ Branch 3 taken 2352176 times.
✓ Branch 4 taken 61002 times.
✓ Branch 5 taken 846958 times.
10186679 if(!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall) || !kb)) //Don't walk into pits, unless being knocked back
1569 {
1570
4/4
✓ Branch 0 taken 3191204 times.
✓ Branch 1 taken 7930 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 3190205 times.
6389416 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1571
4/4
✓ Branch 0 taken 3191005 times.
✓ Branch 1 taken 199 times.
✓ Branch 2 taken 3190282 times.
✓ Branch 3 taken 723 times.
3191204 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1572 8929 return true;
1573 3190205 }
1574
1575
4/4
✓ Branch 0 taken 7810305 times.
✓ Branch 1 taken 2360740 times.
✓ Branch 2 taken 973 times.
✓ Branch 3 taken 5732 times.
10177750 switch(special)
1576 {
1577 case spw_clipbottomright:
1578
4/4
✓ Branch 0 taken 786 times.
✓ Branch 1 taken 187 times.
✓ Branch 2 taken 79 times.
✓ Branch 3 taken 707 times.
973 if(dy>=world_h-48 || dx>=world_w-48) return true;
1579 707 break;
1580 case spw_clipright:
1581 5732 break; //if(input_x>=208) return true; break;
1582
1583 case spw_wizzrobe: // fall through
1584 case spw_floater: // Special case for fliers and wizzrobes - hack!
1585 {
1586
2/2
✓ Branch 0 taken 3168626 times.
✓ Branch 1 taken 4641679 times.
7810305 if(isInDungeon)
1587 {
1588
3/4
✓ Branch 0 taken 4641667 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4641667 times.
4641679 if(dy < 32-yg || dy >= world_h-32) return true;
1589
4/4
✓ Branch 0 taken 4639555 times.
✓ Branch 1 taken 2112 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 4639539 times.
4641667 if(dx < 32 || dx >= world_w-32) return true;
1590 4639539 }
1591 7808165 return false;
1592 }
1593 }
1594
1595 2367179 dx = CLEAR_LOW_BITS(dx, special == spw_halfstep ? 3 : 4);
1596
2/2
✓ Branch 0 taken 564791 times.
✓ Branch 1 taken 1802388 times.
2367179 dy = CLEAR_LOW_BITS(dy, special == spw_halfstep || isSideViewGravity() ? 3 : 4);
1597
1598
2/2
✓ Branch 0 taken 439102 times.
✓ Branch 1 taken 1928077 times.
2367179 if(special==spw_water)
1599
2/2
✓ Branch 0 taken 17784 times.
✓ Branch 1 taken 421318 times.
439102 return (water_walkflag(dx,dy+8,1) || water_walkflag(dx+8,dy+8,1));
1600
1601
2/2
✓ Branch 0 taken 1711908 times.
✓ Branch 1 taken 216169 times.
1928077 if(get_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY))
1602 {
1603
4/4
✓ Branch 0 taken 1228217 times.
✓ Branch 1 taken 483691 times.
✓ Branch 2 taken 1218180 times.
✓ Branch 3 taken 10037 times.
2930088 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1604
2/2
✓ Branch 0 taken 14580 times.
✓ Branch 1 taken 1203600 times.
1218180 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1605 }
1606 else
1607 {
1608
4/4
✓ Branch 0 taken 164129 times.
✓ Branch 1 taken 52040 times.
✓ Branch 2 taken 163777 times.
✓ Branch 3 taken 352 times.
379946 return _walkflag(dx,dy,1) || _walkflag(dx+8,dy,1) ||
1609
4/4
✓ Branch 0 taken 162854 times.
✓ Branch 1 taken 923 times.
✓ Branch 2 taken 162838 times.
✓ Branch 3 taken 16 times.
163777 _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1610
4/4
✓ Branch 0 taken 152476 times.
✓ Branch 1 taken 10362 times.
✓ Branch 2 taken 152461 times.
✓ Branch 3 taken 15 times.
162838 groundblocked(dx,dy,kb) || groundblocked(dx+8,dy,kb) ||
1611
2/2
✓ Branch 0 taken 152158 times.
✓ Branch 1 taken 303 times.
152461 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1612 }
1613 10571176 }
1614
1615 496901 bool enemy::isOnSideviewPlatform()
1616 {
1617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 496901 times.
496901 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH) ? hit_width : 16;
1618
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 496901 times.
496901 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT) ? hit_height : 16;
1619
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 496901 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
496901 if(!get_qr(qr_BROKEN_SIDEVIEW_SPRITE_JUMP)&&fall<0)
1620 return false;
1621
5/6
✓ Branch 0 taken 11630 times.
✓ Branch 1 taken 485271 times.
✓ Branch 2 taken 422 times.
✓ Branch 3 taken 11208 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 422 times.
496901 if(y + usehei >= world_h && cur_screen>=0x70 && !(get_scr_for_world_xy(x, y)->flags2&wfDOWN)) return true; //Bottom of the map
1622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 496479 times.
496479 if(check_slope(x, y+1, usewid, usehei)) return true;
1623
2/2
✓ Branch 0 taken 496479 times.
✓ Branch 1 taken 215641 times.
712120 for(int32_t nx = x + 4; nx <= x + usewid - 4; nx+=16)
1624 {
1625
2/2
✓ Branch 0 taken 215641 times.
✓ Branch 1 taken 280838 times.
496479 if(_walkflag(nx,y+usehei,1)) return true;
1626
3/4
✓ Branch 0 taken 215641 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 151313 times.
✓ Branch 3 taken 64328 times.
215641 if(IGNORE_SIDEVIEW_PLATFORMS || ((int32_t(y)+usehei)%16)!=0) continue;
1627
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64328 times.
64328 if(checkSVLadderPlatform(nx,y+usehei)) return true;
1628 64328 }
1629 215641 return false;
1630 496901 }
1631
1632 // Stops playing the given sound only if there are no enemies left to play it
1633 797513 void enemy::stop_bgsfx(int32_t index)
1634 {
1635
2/2
✓ Branch 0 taken 781310 times.
✓ Branch 1 taken 16203 times.
797513 if(bgsfx<=0)
1636 781310 return;
1637
1638 // Look for other enemies with the same bgsfx
1639
2/2
✓ Branch 0 taken 55203 times.
✓ Branch 1 taken 9313 times.
64516 for(int32_t i=0; i<guys.Count(); i++)
1640 {
1641
4/4
✓ Branch 0 taken 43166 times.
✓ Branch 1 taken 12037 times.
✓ Branch 2 taken 6890 times.
✓ Branch 3 taken 36276 times.
55203 if(i!=index && ((enemy*)guys.spr(i))->bgsfx==bgsfx)
1642 6890 return;
1643 48313 }
1644
1645 9313 stop_sfx(bgsfx);
1646 797513 }
1647
1648
1649 // to allow for different sfx on defeating enemy
1650 41726 void enemy::death_sfx()
1651 {
1652
2/2
✓ Branch 0 taken 41441 times.
✓ Branch 1 taken 285 times.
41726 if(deadsfx > 0) sfx(deadsfx,pan(x));
1653 41726 }
1654
1655 void enemy::move(zfix dx,zfix dy)
1656 {
1657 if(!watch && (!(isSideViewGravity()) || isOnSideviewPlatform() || !(moveflags & move_obeys_grav) || !enemycanfall(id)))
1658 {
1659 x+=dx;
1660 y+=dy;
1661 }
1662 }
1663
1664 19033497 void enemy::move(zfix s)
1665 {
1666
9/10
✓ Branch 0 taken 19033458 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 109109 times.
✓ Branch 3 taken 18924349 times.
✓ Branch 4 taken 58221 times.
✓ Branch 5 taken 50888 times.
✓ Branch 6 taken 1005 times.
✓ Branch 7 taken 57216 times.
✓ Branch 8 taken 1005 times.
✗ Branch 9 not taken.
19033497 if(!watch && (!(isSideViewGravity()) || isOnSideviewPlatform() || !enemycanfall(id) || !(moveflags & move_obeys_grav)))
1667 {
1668 19032453 sprite::move(s);
1669 19032453 }
1670 19033497 }
1671
1672 45202 void enemy::leave_item()
1673 {
1674 45202 int32_t drop_item = select_dropitem(item_set, x, y);
1675 45202 int32_t thedropset = item_set;
1676
1677 45202 std::vector<int32_t> &ev = FFCore.eventData;
1678 45202 ev.clear();
1679 45202 ev.push_back(getUID());
1680 45202 ev.push_back(drop_item*10000);
1681 45202 ev.push_back(thedropset*10000);
1682
1683 45202 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DROP_ITEM_1);
1684 45202 drop_item = vbound(ev[1] / 10000,-2,255);
1685 45202 thedropset = ev[2] / 10000;
1686 45202 ev.clear();
1687
1/2
✓ Branch 0 taken 45202 times.
✗ Branch 1 not taken.
45202 if(drop_item == -2)
1688 {
1689 drop_item = select_dropitem(thedropset,x,y);
1690 }
1691
1692
6/6
✓ Branch 0 taken 17094 times.
✓ Branch 1 taken 28108 times.
✓ Branch 2 taken 921 times.
✓ Branch 3 taken 16173 times.
✓ Branch 4 taken 169 times.
✓ Branch 5 taken 752 times.
45202 if(drop_item>=0&&((itemsbuf[drop_item].type!=itype_fairy)||!m_walkflag(x,y,0,dir)))
1693 {
1694 item* itm;
1695
2/2
✓ Branch 0 taken 549 times.
✓ Branch 1 taken 16376 times.
16925 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
1696 {
1697
10/20
✓ Branch 0 taken 549 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 549 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 549 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 549 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 549 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 549 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 549 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 549 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 549 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 549 times.
✗ Branch 19 not taken.
549 itm = (new item(x+hxofs+(hit_width/2)-8,y+hyofs+(hit_height/2)-8,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1698 549 }
1699 else
1700 {
1701
8/14
✓ Branch 0 taken 1720 times.
✓ Branch 1 taken 14656 times.
✓ Branch 2 taken 1720 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1720 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1720 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1720 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1720 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1720 times.
✗ Branch 13 not taken.
16376 if(extend >= 3) itm = (new item(x+(txsz-1)*8,y+(tysz-1)*8,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1702
4/8
✓ Branch 0 taken 14656 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14656 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14656 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14656 times.
✗ Branch 7 not taken.
14656 else itm = (new item(x,y,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1703 }
1704 16925 itm->from_dropset = thedropset;
1705 16925 add_item_for_screen(screen_spawned, itm);
1706
1707 16925 ev.push_back(getUID());
1708 16925 ev.push_back(itm->getUID());
1709
1710 16925 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DROP_ITEM_2);
1711 16925 ev.clear();
1712 16925 }
1713 45202 }
1714
1715 // auomatically kill off enemy (for rooms with ringleaders)
1716 419 void enemy::kickbucket()
1717 {
1718
3/4
✓ Branch 0 taken 387 times.
✓ Branch 1 taken 32 times.
✓ Branch 2 taken 387 times.
✗ Branch 3 not taken.
419 if(!superman && !(flags&guy_ignore_kill_all))
1719 387 hp=-1000; // don't call death_sfx()
1720 419 }
1721
1722 27212 bool enemy::isSubmerged() const
1723 {
1724 27212 return submerged;
1725 //!TODO SOLIDPUSH more things like teleporting wizzrobes
1726 }
1727
1728 20952 void enemy::FireBreath(bool seekhero)
1729 {
1730
1/2
✓ Branch 0 taken 20952 times.
✗ Branch 1 not taken.
20952 if(wpn==wNone)
1731 return;
1732
1733
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20952 times.
20952 if(wpn==ewFireTrail)
1734 {
1735 dmisc1 = e1tEACHTILE;
1736 FireWeapon();
1737 return;
1738 }
1739
1740 20952 float fire_angle=0.0;
1741 20952 int32_t wx=0, wy=0, wdir=dir, xoff=0, yoff=0;
1742
1743
1/2
✓ Branch 0 taken 20952 times.
✗ Branch 1 not taken.
20952 if (SIZEflags & OVERRIDE_HIT_WIDTH)
1744 {
1745 xoff += hxofs;
1746 if (weap_data.override_flags & OVERRIDE_HIT_WIDTH)
1747 xoff += (hit_width / 2) - (weap_data.tilew * 8);
1748 else
1749 xoff += (hit_width / 2) - 8;
1750 }
1751
1/2
✓ Branch 0 taken 20952 times.
✗ Branch 1 not taken.
20952 if (SIZEflags & OVERRIDE_HIT_HEIGHT)
1752 {
1753 yoff += hyofs;
1754 if (weap_data.override_flags & OVERRIDE_HIT_HEIGHT)
1755 yoff += (hit_height / 2) - (weap_data.tileh * 8);
1756 else
1757 yoff += (hit_height / 2) - 8;
1758 }
1759
1760
2/2
✓ Branch 0 taken 5081 times.
✓ Branch 1 taken 15871 times.
20952 if(!seekhero)
1761 {
1762
4/5
✓ Branch 0 taken 3297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3079 times.
✓ Branch 3 taken 5287 times.
✓ Branch 4 taken 4208 times.
15871 switch(dir)
1763 {
1764 case down:
1765 3079 fire_angle=PI*(int64_t(zc_oldrand()%20)+10)/40;
1766 3079 wx=x;
1767 3079 wy=y+8;
1768 3079 break;
1769
1770 case -1:
1771 case up:
1772 3297 fire_angle=PI*(int64_t(zc_oldrand()%20)+50)/40;
1773 3297 wx=x;
1774 3297 wy=y-8;
1775 3297 break;
1776
1777 case left:
1778 5287 fire_angle=PI*(int64_t(zc_oldrand()%20)+30)/40;
1779 5287 wx=x-8;
1780 5287 wy=y;
1781 5287 break;
1782
1783 case right:
1784 4208 fire_angle=PI*(int64_t(zc_oldrand()%20)+70)/40;
1785 4208 wx=x+8;
1786 4208 wy=y;
1787 4208 break;
1788 }
1789
1790
3/4
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 15735 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 136 times.
15871 if(wpn==ewFlame || wpn==ewFlame2)
1791 {
1792
2/4
✓ Branch 0 taken 15735 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15735 times.
15735 if(fire_angle==-PI || fire_angle==PI) wdir=left;
1793
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle==-PI/2) wdir=up;
1794
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle==PI/2) wdir=down;
1795
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle==0) wdir=right;
1796
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle<-PI/2) wdir=l_up;
1797
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle<0) wdir=r_up;
1798
2/2
✓ Branch 0 taken 1498 times.
✓ Branch 1 taken 14237 times.
15735 else if(fire_angle<(PI/2)) wdir=r_down;
1799
2/2
✓ Branch 0 taken 10121 times.
✓ Branch 1 taken 4116 times.
14237 else if(fire_angle<PI) wdir=l_down;
1800 15735 }
1801 15871 }
1802 else
1803 {
1804 5081 wx = x;
1805 5081 wy = y;
1806 }
1807
1808
2/2
✓ Branch 0 taken 5081 times.
✓ Branch 1 taken 15871 times.
20952 addEwpn(wx+xoff,wy+yoff,z,wpn,2,wdp,seekhero ? 0xFF : wdir, getUID(), 0, fakez);
1809 20952 sfx(wpnsfx(wpn),pan(x));
1810
1811 20952 int32_t i=Ewpns.Count()-1;
1812 20952 weapon *ew = (weapon*)(Ewpns.spr(i));
1813 20952 ew->moveflags &= ~move_can_pitfall; //No falling in pits
1814
1815
4/4
✓ Branch 0 taken 15871 times.
✓ Branch 1 taken 5081 times.
✓ Branch 2 taken 7914 times.
✓ Branch 3 taken 7957 times.
20952 if(!seekhero && (zc_oldrand()&4))
1816 {
1817 7957 ew->angular=true;
1818 7957 ew->angle=fire_angle;
1819 7957 }
1820
1821
4/4
✓ Branch 0 taken 20676 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 317 times.
✓ Branch 3 taken 20359 times.
20952 if(wpn==ewFlame && wpnsbuf[ewFLAME].frames>1)
1822 {
1823 20359 ew->aframe=zc_oldrand()%wpnsbuf[ewFLAME].frames;
1824
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20359 times.
20359 if ( ew->do_animation ) ew->tile+=ew->aframe;
1825 20359 }
1826
1827
2/2
✓ Branch 0 taken 20952 times.
✓ Branch 1 taken 766199 times.
787151 for(int32_t j=Ewpns.Count()-1; j>0; j--)
1828 {
1829 766199 Ewpns.swap(j,j-1);
1830 766199 }
1831 20952 }
1832
1833 45994 void enemy::FireWeapon()
1834 {
1835 /*
1836 * Type:
1837 * 0x01: Boss fireball
1838 * 0x02: Seeks Hero
1839 * 0x04: Fast projectile
1840 * 0x00-0x30: If 0x02, slants toward (type>>3)-1
1841 */
1842
1843
2/2
✓ Branch 0 taken 45863 times.
✓ Branch 1 taken 131 times.
45994 if (wpn < 1) return;
1844
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 45863 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
45863 if(wpn<wEnemyWeapons && dmisc1!=9 && dmisc1!=10 && (wpn < wScript1 && wpn > wScript10) ) // Summoning doesn't require weapons
1845 return;
1846
1847
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 45863 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
45863 if(wpn==ewFireTrail && dmisc1>=e1t3SHOTS && dmisc1<=e1t8SHOTS)
1848 dmisc1 = e1tEACHTILE;
1849
1850 45863 int32_t xoff = 0;
1851 45863 int32_t yoff = 0;
1852
1/2
✓ Branch 0 taken 45863 times.
✗ Branch 1 not taken.
45863 if (SIZEflags & OVERRIDE_HIT_WIDTH)
1853 {
1854 xoff += hxofs;
1855 if (weap_data.override_flags & OVERRIDE_HIT_WIDTH)
1856 xoff += (hit_width / 2) - (weap_data.tilew * 8);
1857 else
1858 xoff += (hit_width / 2) - 8;
1859 }
1860
1/2
✓ Branch 0 taken 45863 times.
✗ Branch 1 not taken.
45863 if (SIZEflags & OVERRIDE_HIT_HEIGHT)
1861 {
1862 yoff += hyofs;
1863 if (weap_data.override_flags & OVERRIDE_HIT_HEIGHT)
1864 yoff += (hit_height / 2) - (weap_data.tileh * 8);
1865 else
1866 yoff += (hit_height / 2) - 8;
1867 }
1868
1869 // TODO(crash): check that .add succeeds.
1870
1871
5/8
✓ Branch 0 taken 646 times.
✓ Branch 1 taken 42856 times.
✓ Branch 2 taken 1839 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 424 times.
✓ Branch 5 taken 98 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
45863 switch(dmisc1)
1872 {
1873 case e1t5SHOTS: //BS-Aquamentus
1874 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^left)+5)<<3),wdp,dir,-1, getUID(),false));
1875 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1876 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^right)+5)<<3),wdp,dir,-1, getUID(),false));
1877 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1878
1879 [[fallthrough]];
1880 case e1t3SHOTSFAST:
1881 case e1t3SHOTS: //Aquamentus
1882
7/14
✓ Branch 0 taken 646 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 646 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 646 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 646 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 646 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 646 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 646 times.
✗ Branch 13 not taken.
646 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^left)+1)<<3)+(dmisc1==e1t3SHOTSFAST ? 4:0),wdp,dir,-1, getUID(),false));
1883 646 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1884
7/14
✓ Branch 0 taken 646 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 646 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 646 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 646 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 646 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 646 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 646 times.
✗ Branch 13 not taken.
646 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^right)+1)<<3)+(dmisc1==e1t3SHOTSFAST ? 4:0),wdp,dir,-1, getUID(),false));
1885 646 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1886
1887 [[fallthrough]];
1888 default:
1889
12/20
✓ Branch 0 taken 43502 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 43502 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 43502 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 43502 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 43502 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 5 times.
✓ Branch 11 taken 43497 times.
✓ Branch 12 taken 43502 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 18238 times.
✓ Branch 15 taken 25264 times.
✓ Branch 16 taken 43502 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 43502 times.
✗ Branch 19 not taken.
43502 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(dmisc1==e1t3SHOTSFAST || dmisc1==e1tFAST ? 4:0),wdp,wpn==ewFireball2 || wpn==ewFireball ? 0:dir,-1, getUID(),false));
1890 43502 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1891 43502 sfx(wpnsfx(wpn),pan(x));
1892 43502 break;
1893
1894 case e1tSLANT:
1895 {
1896 424 int32_t slant = 0;
1897
1898
10/10
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 312 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 224 times.
✓ Branch 4 taken 47 times.
✓ Branch 5 taken 153 times.
✓ Branch 6 taken 61 times.
✓ Branch 7 taken 316 times.
✓ Branch 8 taken 138 times.
✓ Branch 9 taken 178 times.
424 if(((Hero.x-x) < -8 && dir==up) || ((Hero.x-x) > 8 && dir==down) || ((Hero.y-y) < -8 && dir==left) || ((Hero.y-y) > 8 && dir==right))
1899 246 slant = left;
1900
10/10
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 68 times.
✓ Branch 3 taken 110 times.
✓ Branch 4 taken 37 times.
✓ Branch 5 taken 31 times.
✓ Branch 6 taken 55 times.
✓ Branch 7 taken 86 times.
✓ Branch 8 taken 25 times.
✓ Branch 9 taken 61 times.
178 else if(((Hero.x-x) > 8 && dir==up) || ((Hero.x-x) < -8 && dir==down) || ((Hero.y-y) > 8 && dir==left) || ((Hero.y-y) < -8 && dir==right))
1901 117 slant = right;
1902
1903
9/18
✓ Branch 0 taken 330 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 330 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 330 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 330 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 330 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 330 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 330 times.
✓ Branch 14 taken 330 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 330 times.
✗ Branch 17 not taken.
330 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^slant)+1)<<3),wdp,wpn==ewFireball2 || wpn==ewFireball ? 0:dir,-1, getUID(),false));
1904 330 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1905 330 sfx(wpnsfx(wpn),pan(x));
1906 330 break;
1907 }
1908
1909 case e1t8SHOTS: //Fire Wizzrobe
1910
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,l_up,-1, getUID(),false));
1911 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1912 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1913
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,l_down,-1, getUID(),false));
1914 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1915 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1916
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,r_up,-1, getUID(),false));
1917 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1918 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1919
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,r_down,-1, getUID(),false));
1920 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1921 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1922
1923 [[fallthrough]];
1924 case e1t4SHOTS: //Stalfos 3
1925
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,up,-1, getUID(),false));
1926 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1927 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1928
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,down,-1, getUID(),false));
1929 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1930 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1931
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,left,-1, getUID(),false));
1932 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1933 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1934
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,right,-1, getUID(),false));
1935 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1936 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1937 1937 sfx(wpnsfx(wpn),pan(x));
1938 1937 break;
1939
1940 case e1tSUMMON: // Bat Wizzrobe
1941 {
1942 if(dmisc4==0) break; // Summon 0
1943
1944 int32_t bc=0;
1945
1946 for(int32_t gc=0; gc<guys.Count(); gc++)
1947 {
1948 if((((enemy*)guys.spr(gc))->id) == dmisc3)
1949 {
1950 ++bc;
1951 }
1952 }
1953
1954 if(bc<=40) // Not too many enemies
1955 {
1956 int32_t kids = guys.Count();
1957 int32_t bats=(zc_oldrand()%zc_max(1,dmisc4))+1;
1958
1959 for(int32_t i=0; i<bats; i++)
1960 {
1961 if(addchild(screen_spawned,x,y,dmisc3,-10, this))
1962 {
1963 ((enemy*)guys.spr(kids+i))->count_enemy = false;
1964 }
1965 }
1966
1967 sfx(firesfx, pan(x));
1968 }
1969
1970 break;
1971 }
1972
1973 case e1tSUMMONLAYER: // Summoner
1974 {
1975 if(count_layer_enemies(screen_spawned)==0)
1976 {
1977 break;
1978 }
1979
1980 int32_t kids = guys.Count();
1981
1982 if(kids<40)
1983 {
1984 int32_t newguys=(zc_oldrand()%3)+1;
1985 bool summoned=false;
1986
1987 for(int32_t i=0; i<newguys; i++)
1988 {
1989 int32_t id2=vbound(random_layer_enemy(screen_spawned),eSTART,eMAXGUYS-1);
1990 int32_t x2=0;
1991 int32_t y2=0;
1992
1993 for(int32_t k=0; k<20; ++k)
1994 {
1995 x2=16*((zc_oldrand()%12)+2);
1996 y2=16*((zc_oldrand()%7)+2);
1997
1998 if((!m_walkflag(x2,y2,0,dir))&&((abs(x2-Hero.getX())>=32)||(abs(y2-Hero.getY())>=32)))
1999 {
2000 if(addchild_z(screen_spawned,x2,y2,get_qr(qr_ENEMIESZAXIS) ? 64 : 0,id2,-10, this))
2001 {
2002 ((enemy*)guys.spr(kids+i))->count_enemy = false;
2003 if (get_qr(qr_ENEMIESZAXIS) && (((enemy*)guys.spr(kids+i))->moveflags & move_use_fake_z))
2004 {
2005 ((enemy*)guys.spr(kids+i))->fakez = 64;
2006 ((enemy*)guys.spr(kids+i))->z = 0;
2007 }
2008 }
2009
2010 summoned=true;
2011 break;
2012 }
2013 }
2014 }
2015
2016 if(summoned)
2017 {
2018 sfx(firesfx, pan(x));
2019 }
2020 }
2021
2022 break;
2023 }
2024 }
2025 45900 }
2026
2027
2028 // Hit the shield(s)?
2029 // Apparently, this function is only used for hookshots...
2030 2767 bool enemy::hitshield(int32_t wpnx, int32_t wpny, int32_t xdir)
2031 {
2032
6/6
✓ Branch 0 taken 976 times.
✓ Branch 1 taken 1791 times.
✓ Branch 2 taken 975 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 141 times.
✓ Branch 5 taken 834 times.
2767 if(!(type==eeWALK || type==eeFIRE || type==eeOTHER))
2033 834 return false;
2034
2035 1933 bool ret = false;
2036
2037 // TODO: There must be some bitwise operations that can simplify this...
2038
9/12
✓ Branch 0 taken 1207 times.
✓ Branch 1 taken 726 times.
✓ Branch 2 taken 43 times.
✓ Branch 3 taken 683 times.
✓ Branch 4 taken 27 times.
✓ Branch 5 taken 16 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 699 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 699 times.
✓ Branch 10 taken 699 times.
✗ Branch 11 not taken.
1933 if(wpny > y) ret = ((flags&guy_shield_front && xdir==down) || (flags&guy_shield_back && xdir==up) || (flags&guy_shield_left && xdir==left) || (flags&guy_shield_right && xdir==right));
2039
9/12
✓ Branch 0 taken 383 times.
✓ Branch 1 taken 824 times.
✓ Branch 2 taken 46 times.
✓ Branch 3 taken 778 times.
✓ Branch 4 taken 33 times.
✓ Branch 5 taken 13 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 811 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 811 times.
✓ Branch 10 taken 811 times.
✗ Branch 11 not taken.
1207 else if(wpny < y) ret = ((flags&guy_shield_front && xdir==up) || (flags&guy_shield_back && xdir==down) || (flags&guy_shield_left && xdir==right) || (flags&guy_shield_right && xdir==left));
2040
2041
11/14
✓ Branch 0 taken 1065 times.
✓ Branch 1 taken 868 times.
✓ Branch 2 taken 19 times.
✓ Branch 3 taken 849 times.
✓ Branch 4 taken 24 times.
✓ Branch 5 taken 825 times.
✓ Branch 6 taken 9 times.
✓ Branch 7 taken 15 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 840 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 840 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 840 times.
1933 if(wpnx < x) ret = ret || ((flags&guy_shield_front && xdir==left) || (flags&guy_shield_back && xdir==right) || (flags&guy_shield_left && xdir==down) || (flags&guy_shield_right && xdir==up));
2042
11/14
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 876 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 863 times.
✓ Branch 4 taken 36 times.
✓ Branch 5 taken 827 times.
✓ Branch 6 taken 19 times.
✓ Branch 7 taken 17 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 844 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 844 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 844 times.
1065 else if(wpnx > x) ret = ret || ((flags&guy_shield_front && xdir==right) || (flags&guy_shield_back && xdir==left) || (flags&guy_shield_left && xdir==up) || (flags&guy_shield_right && xdir==down));
2043
2044 1933 return ret;
2045 2767 }
2046
2047
2048 //! Weapon Editor for 2.6
2049 //To hell with this. I'm writing new functions to resolve weapon type and defence. -Z
2050
2051
2052 //converts a wqeapon ID to its defence index.
2053 136228 int32_t weaponToDefence(int32_t wid)
2054 {
2055
23/47
✗ Branch 0 not taken.
✓ Branch 1 taken 67251 times.
✓ Branch 2 taken 9439 times.
✓ Branch 3 taken 25184 times.
✓ Branch 4 taken 4409 times.
✓ Branch 5 taken 37 times.
✓ Branch 6 taken 48 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3334 times.
✓ Branch 9 taken 10907 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 269 times.
✓ Branch 13 taken 1438 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 512 times.
✓ Branch 17 taken 1459 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 2153 times.
✓ Branch 20 taken 2767 times.
✓ Branch 21 taken 610 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 240 times.
✓ Branch 24 taken 486 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 19 times.
✗ Branch 29 not taken.
✓ Branch 30 taken 4583 times.
✗ Branch 31 not taken.
✓ Branch 32 taken 12 times.
✓ Branch 33 taken 77 times.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✓ Branch 39 taken 993 times.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✓ Branch 42 taken 1 times.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✗ Branch 46 not taken.
136228 switch(wid)
2056 {
2057 case wNone: return -1;
2058 67251 case wSword: return edefSWORD;
2059 9439 case wBeam: return edefBEAM;
2060 25184 case wBrang: return edefBRANG;
2061 4409 case wBomb: return edefBOMB;
2062 37 case wSBomb: return edefSBOMB;
2063 48 case wLitBomb: return edefBOMB;
2064 case wLitSBomb: return edefSBOMB;
2065 3334 case wArrow: return edefARROW;
2066 10907 case wFire: return edefFIRE;
2067 case wWhistle:
2068 {
2069 return edefWhistle;
2070 }
2071 case wBait: return edefBAIT;
2072 269 case wWand: return edefWAND;
2073 1438 case wMagic: return edefMAGIC;
2074 case wCatching: return -1;
2075 case wWind: return edefWIND;
2076 512 case wRefMagic: return edefREFMAGIC;
2077 1459 case wRefFireball: return edefREFBALL;
2078 case wRefRock: return edefREFROCK;
2079 2153 case wHammer: return edefHAMMER;
2080 2767 case wHookshot: return edefHOOKSHOT;
2081 610 case wHSHandle: return edefHOOKSHOT;
2082 case wHSChain: return edefHOOKSHOT;
2083 240 case wSSparkle: return edefSPARKLE;
2084 486 case wFSparkle: return edefSPARKLE;
2085 case wSmack: return -1; // is this the candle object?
2086 case wPhantom: return -1; //engine created visual effects.
2087 case wCByrna: return edefBYRNA;
2088 19 case wRefBeam: return edefREFBEAM;
2089 case wStomp: return edefSTOMP;
2090 4583 case wScript1: return edefSCRIPT01;
2091 case wScript2: return edefSCRIPT02;
2092 12 case wScript3: return edefSCRIPT03;
2093 77 case wScript4: return edefSCRIPT04;
2094 case wScript5: return edefSCRIPT05;
2095 case wScript6: return edefSCRIPT06;
2096 case wScript7: return edefSCRIPT07;
2097 case wScript8: return edefSCRIPT08;
2098 case wScript9: return edefSCRIPT09;
2099 993 case wScript10: return edefSCRIPT10;
2100 case wIce: return edefICE;
2101 case wSound: return edefSONIC;
2102 1 case wThrown: return edefTHROWN;
2103 case wRefArrow: return edefREFARROW;
2104 case wRefFire: return edefREFFIRE;
2105 case wRefFire2: return edefREFFIRE2;
2106 //case wPot: return edefPOT;
2107 // case wLitZap: return edefELECTRIC;
2108 // case wZ3Sword: return edefZ3SWORD;
2109 // case wLASWord: return edefLASWORD;
2110 // case wSpinAttk: return edefSPINATTK;
2111 // case wShield: return edefSHIELD;
2112 // case wTrowel: return edefTROWEL;
2113
2114 default: return -1;
2115 }
2116 136228 }
2117
2118 136228 int32_t getDefType(weapon *w)
2119 {
2120 136228 int32_t id = getWeaponID(w);
2121 136228 int32_t edef = weaponToDefence(id);
2122
2/2
✓ Branch 0 taken 132851 times.
✓ Branch 1 taken 3377 times.
136228 if(edef == edefHOOKSHOT)
2123 {
2124
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3377 times.
3377 if(w->family_class == itype_switchhook)
2125 return edefSwitchHook;
2126 3377 }
2127 136228 return edef;
2128 136228 }
2129
2130 244505 int32_t getWeaponID(weapon *w)
2131 {
2132 244505 int32_t usewpn = w->useweapon;
2133
2/2
✓ Branch 0 taken 230 times.
✓ Branch 1 taken 244275 times.
244505 return (usewpn > 0) ? usewpn : w->id;
2134 }
2135
2136 136228 int32_t enemy::resolveEnemyDefence(weapon *w)
2137 {
2138 //sword edef is 9, but we're reading it at 0
2139 //,
2140 136228 int32_t weapondef = 0;
2141 136228 int32_t wdeftype = getDefType(w);
2142 136228 int32_t usedef = w->usedefense;
2143
2144
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 136228 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
136228 if ( usedef > 0 && (wdeftype < 0 || wdeftype >= edefLAST255 || defense[wdeftype] == 0))
2145 {
2146 weapondef = usedef*-1;
2147 }
2148
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 136228 times.
136228 else if(unsigned(wdeftype) < edefLAST255)
2149 {
2150 136228 weapondef = wdeftype;
2151 136228 }
2152 136228 return weapondef;
2153 }
2154
2155 147104 byte get_def_ignrflag(int32_t edef)
2156 {
2157
3/3
✓ Branch 0 taken 119115 times.
✓ Branch 1 taken 3702 times.
✓ Branch 2 taken 24287 times.
147104 switch(edef)
2158 {
2159 case edIGNORE:
2160 case edIGNOREL1:
2161 case edSTUNORIGNORE:
2162 24287 return WPNUNB_IGNR;
2163 case edSTUNORCHINK:
2164 case edCHINK:
2165 case edCHINKL1:
2166 case edCHINKL2:
2167 case edCHINKL4:
2168 case edCHINKL6:
2169 case edCHINKL8:
2170 case edCHINKL10:
2171 case edLEVELCHINK2:
2172 case edLEVELCHINK3:
2173 case edLEVELCHINK4:
2174 case edLEVELCHINK5:
2175 3702 return WPNUNB_BLOCK;
2176 }
2177 119115 return 0;
2178 147104 }
2179
2180 147104 int32_t conv_edef_unblockable(int32_t edef, byte unblockable)
2181 {
2182
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147104 times.
147104 if(!(unblockable&get_def_ignrflag(edef))) return edef;
2183 switch(edef)
2184 {
2185 case edIGNORE:
2186 case edIGNOREL1:
2187 case edCHINK:
2188 case edCHINKL1:
2189 case edCHINKL2:
2190 case edCHINKL4:
2191 case edCHINKL6:
2192 case edCHINKL8:
2193 case edCHINKL10:
2194 case edLEVELCHINK2:
2195 case edLEVELCHINK3:
2196 case edLEVELCHINK4:
2197 case edLEVELCHINK5:
2198 return edNORMAL;
2199 case edSTUNORIGNORE:
2200 case edSTUNORCHINK:
2201 return edSTUNONLY;
2202 }
2203 return edef;
2204 147104 }
2205
2206 // Do we do damage?
2207 // 0: takehit returns 0
2208 // 1: takehit returns 1
2209 // -1: do damage
2210 //The input from resolveEnemyDefence() for the param 'edef' is negative if a specific defence RESULT is being used.
2211 135235 int32_t enemy::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable) //May need *wpn to set return on brangs and hookshots
2212 {
2213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 135235 times.
135235 if(switch_hooked) return 0;
2214 135235 int32_t tempx = x;
2215 135235 int32_t tempy = y;
2216 135235 int32_t the_defence = 0;
2217
1/2
✓ Branch 0 taken 135235 times.
✗ Branch 1 not taken.
135235 if ( edef < 0 ) //we are using a specific base default defence for a weapon
2218 {
2219 the_defence = edef*-1; //A specific defence type.
2220 }
2221 135235 else the_defence = defense[edef];
2222
2223 135235 the_defence = conv_edef_unblockable(the_defence, unblockable);
2224
2225
3/4
✓ Branch 0 taken 6811 times.
✓ Branch 1 taken 128424 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6811 times.
135235 if(shieldCanBlock && !(unblockable&WPNUNB_SHLD))
2226 {
2227
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 6804 times.
✓ Branch 2 taken 7 times.
6811 switch(the_defence)
2228 {
2229 case edIGNORE:
2230 7 return 0;
2231 case edIGNOREL1:
2232 case edSTUNORIGNORE:
2233 if(*power <= 0)
2234 return 0;
2235 }
2236 6804 sfx(WAV_CHINK,pan(x));
2237 6804 return 1;
2238 }
2239
2240 128424 int32_t new_id = id;
2241 128424 int32_t effect_type = dmisc15;
2242 128424 int32_t delay_timer = 90;
2243 128424 enemy *gleeok = NULL;
2244 128424 enemy *ptra = NULL;
2245 128424 int32_t c = 0;
2246
2247
17/29
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 525 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1935 times.
✓ Branch 6 taken 1958 times.
✓ Branch 7 taken 113 times.
✓ Branch 8 taken 129 times.
✓ Branch 9 taken 1 times.
✓ Branch 10 taken 43 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 963 times.
✓ Branch 13 taken 22345 times.
✓ Branch 14 taken 1007 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 2175 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✓ Branch 22 taken 497 times.
✓ Branch 23 taken 8 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 158 times.
✓ Branch 26 taken 181 times.
✓ Branch 27 taken 4 times.
✓ Branch 28 taken 96382 times.
128424 switch(the_defence)
2248 {
2249 case edREPLACE:
2250 {
2251 sclk = 0;
2252 if ( dmisc16 > 0 ) new_id = dmisc16;
2253 else new_id = id+1;
2254 if ( new_id > 511 ) new_id = id; //Sanity bound to legal enemy IDs.
2255 if ( dmisc17 > 0 ) delay_timer = dmisc17;
2256 //if ( dmisc18 > 0 ) dummy_wpn_id = dmisc18;
2257
2258 //Z_scripterrlog("new id is %d\n", new_id);
2259 switch(guysbuf[new_id&0xFFF].type)
2260 {
2261 //Fixme: possible enemy memory leak. (minor)
2262 case eeWALK:
2263 {
2264 enemy *e = new eStalfos(x,y,new_id,clk);
2265 guys.add(e);
2266 }
2267 break;
2268
2269 case eeLEV:
2270 {
2271 enemy *e = new eLeever(x,y,new_id,clk);
2272 guys.add(e);
2273 }
2274 break;
2275
2276 case eeTEK:
2277 {
2278 enemy *e = new eTektite(x,y,new_id,clk);
2279 guys.add(e);
2280 }
2281 break;
2282
2283 case eePEAHAT:
2284 {
2285 enemy *e = new ePeahat(x,y,new_id,clk);
2286 guys.add(e);
2287 }
2288 break;
2289
2290 case eeZORA:
2291 {
2292 enemy *e = new eZora(x,y,new_id,clk);
2293 guys.add(e);
2294 }
2295 break;
2296
2297 case eeGHINI:
2298 {
2299 enemy *e = new eGhini(x,y,new_id,clk);
2300 guys.add(e);
2301 }
2302 break;
2303
2304 case eeKEESE:
2305 {
2306 enemy *e = new eKeese(x,y,new_id,clk);
2307 guys.add(e);
2308 }
2309 break;
2310
2311 case eeWIZZ:
2312 {
2313 enemy *e = new eWizzrobe(x,y,new_id,clk);
2314 guys.add(e);
2315 }
2316 break;
2317
2318 case eePROJECTILE:
2319 {
2320 enemy *e = new eProjectile(x,y,new_id,clk);
2321 guys.add(e);
2322 }
2323 break;
2324
2325 case eeWALLM:
2326 {
2327 enemy *e = new eWallM(x,y,new_id,clk);
2328 guys.add(e);
2329 }
2330 break;
2331
2332 case eeAQUA:
2333 {
2334 enemy *e = new eAquamentus(x,y,new_id,clk);
2335 guys.add(e);
2336 e->x = x;
2337 e->y = y;
2338 }
2339 break;
2340
2341 case eeMOLD:
2342 {
2343 enemy *e = new eMoldorm(x,y,new_id,zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].attributes[0])));
2344 guys.add(e);
2345 e->x = x;
2346 e->y = y;
2347 }
2348 break;
2349
2350 case eeMANHAN:
2351 {
2352 enemy *e = new eManhandla(x,y,new_id,clk);
2353 guys.add(e);
2354 e->x = x;
2355 e->y = y;
2356 }
2357 break;
2358
2359 case eeGLEEOK:
2360 {
2361 *power = 0;
2362 gleeok = new eGleeok(x,y,new_id,guysbuf[new_id&0xFFF].attributes[0]);
2363 guys.add(gleeok);
2364 // TODO(crash): check that .add succeeds.
2365 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2366 new_id &= 0xFFF;
2367 int32_t head_cnt = zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].attributes[0]));
2368 Z_scripterrlog("Gleeok head count is %d\n",head_cnt);
2369 for(int32_t i=0; i<head_cnt; i++)
2370 {
2371 //enemy *e = new esGleeok(x,y,new_id+0x1000,clk,gleeok);
2372 if(!guys.add(new esGleeok((zfix)x,(zfix)y,new_id+0x1000,c, gleeok)))
2373 {
2374 al_trace("Gleeok head %d could not be created!\n",i+1);
2375
2376 for(int32_t j=0; j<i+1; j++)
2377 {
2378 guys.del(guys.Count()-1);
2379 }
2380
2381 break;
2382 }
2383 else
2384 {
2385 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2386 }
2387
2388 c-=guysbuf[new_id].attributes[3];
2389 }
2390 return 1;
2391 }
2392
2393 case eeGHOMA:
2394 {
2395 enemy *e = new eGohma(x,y,new_id,clk);
2396 guys.add(e);
2397 e->x = x;
2398 e->y = y;
2399 }
2400 break;
2401
2402 case eeLANM:
2403 {
2404 enemy *e = new eLanmola(x,y,new_id,zc_max(1,zc_min(253,guysbuf[new_id&0xFFF].attributes[0])));
2405 guys.add(e);
2406 e->x = x;
2407 e->y = y;
2408 }
2409 break;
2410
2411 case eeGANON:
2412 {
2413 enemy *e = new eGanon(x,y,new_id,clk);
2414 guys.add(e);
2415 e->x = x;
2416 e->y = y;
2417 }
2418 break;
2419
2420 case eeFAIRY:
2421 {
2422 enemy *e = new eItemFairy(x,y,new_id+0x1000*clk,clk);
2423 guys.add(e);
2424 e->x = x;
2425 e->y = y;
2426 }
2427 break;
2428
2429 case eeFIRE:
2430 {
2431 enemy *e = new eFire(x,y,new_id,clk);
2432 guys.add(e);
2433 e->x = x;
2434 e->y = y;
2435 }
2436 break;
2437
2438 case eeOTHER:
2439 {
2440 enemy *e = new eOther(x,y,new_id,clk);
2441 guys.add(e);
2442 e->x = x;
2443 e->y = y;
2444 }
2445 break;
2446
2447 case eeSPINTILE:
2448 {
2449 enemy *e = new eSpinTile(x,y,new_id,clk);
2450 guys.add(e);
2451 e->x = x;
2452 e->y = y;
2453 }
2454 break;
2455
2456 // and these enemies use the misc10/misc2 value
2457 case eeROCK:
2458 {
2459 switch(guysbuf[new_id&0xFFF].attributes[9])
2460 {
2461 case 1:
2462 {
2463 enemy *e = new eBoulder(x,y,new_id,clk);
2464 guys.add(e);
2465 e->x = x;
2466 e->y = y;
2467 }
2468 break;
2469
2470 case 0:
2471 default:
2472 {
2473 enemy *e = new eRock(x,y,new_id,clk);
2474 guys.add(e);
2475 e->x = x;
2476 e->y = y;
2477 }
2478 break;
2479 }
2480
2481 break;
2482 }
2483
2484 case eeTRAP:
2485 {
2486 switch(guysbuf[new_id&0xFFF].attributes[1])
2487 {
2488 case 1:
2489 {
2490 enemy *e = new eTrap2(x,y,new_id,clk);
2491 guys.add(e);
2492 e->x = x;
2493 e->y = y;
2494 }
2495 break;
2496
2497 case 0:
2498 default:
2499 {
2500 enemy *e = new eTrap(x,y,new_id,clk);
2501 guys.add(e);
2502 e->x = x;
2503 e->y = y;
2504 }
2505 break;
2506 }
2507
2508 break;
2509 }
2510
2511 case eeDONGO:
2512 {
2513 switch(guysbuf[new_id&0xFFF].attributes[9])
2514 {
2515 case 1:
2516 {
2517 enemy *e = new eDodongo2(x,y,new_id,clk);
2518 guys.add(e);
2519 e->x = x;
2520 e->y = y;
2521 }
2522 break;
2523
2524 case 0:
2525 default:
2526 {
2527 enemy *e = new eDodongo(x,y,new_id,clk);
2528 guys.add(e);
2529 e->x = x;
2530 e->y = y;
2531 }
2532 break;
2533 }
2534
2535 break;
2536 }
2537
2538 case eeDIG:
2539 {
2540 switch(guysbuf[new_id&0xFFF].attributes[9])
2541 {
2542 case 1:
2543 {
2544 enemy *e = new eLilDig(x,y,new_id,clk);
2545 guys.add(e);
2546 e->x = x;
2547 e->y = y;
2548 }
2549 break;
2550
2551 case 0:
2552 default:
2553 {
2554 enemy *e = new eBigDig(x,y,new_id,clk);
2555 guys.add(e);
2556 e->x = x;
2557 e->y = y;
2558 }
2559 break;
2560 }
2561
2562 break;
2563 }
2564
2565 case eePATRA:
2566 {
2567 switch(guysbuf[new_id&0xFFF].attributes[9])
2568 {
2569 case 1:
2570 {
2571 if (get_qr(qr_HARDCODED_BS_PATRA))
2572 {
2573 enemy *e = new ePatraBS(x,y,new_id,clk);
2574 guys.add(e);
2575 e->x = x;
2576 e->y = y;
2577 break;
2578 }
2579 }
2580 [[fallthrough]];
2581 case 0:
2582 default:
2583 {
2584 enemy *e = new ePatra(x,y,new_id,clk);
2585 guys.add(e);
2586 e->x = x;
2587 e->y = y;
2588 }
2589 break;
2590 }
2591
2592 break;
2593 }
2594
2595 case eeGUY:
2596 {
2597 switch(guysbuf[new_id&0xFFF].attributes[9])
2598 {
2599 case 1:
2600 {
2601 enemy *e = new eTrigger(x,y,new_id,clk);
2602 guys.add(e);
2603 }
2604 break;
2605
2606 case 0:
2607 default:
2608 {
2609 enemy *e = new eNPC(x,y,new_id,clk);
2610 guys.add(e);
2611 }
2612 break;
2613 }
2614
2615 break;
2616 }
2617
2618 case eeSCRIPT01:
2619 case eeSCRIPT02:
2620 case eeSCRIPT03:
2621 case eeSCRIPT04:
2622 case eeSCRIPT05:
2623 case eeSCRIPT06:
2624 case eeSCRIPT07:
2625 case eeSCRIPT08:
2626 case eeSCRIPT09:
2627 case eeSCRIPT10:
2628 case eeSCRIPT11:
2629 case eeSCRIPT12:
2630 case eeSCRIPT13:
2631 case eeSCRIPT14:
2632 case eeSCRIPT15:
2633 case eeSCRIPT16:
2634 case eeSCRIPT17:
2635 case eeSCRIPT18:
2636 case eeSCRIPT19:
2637 case eeSCRIPT20:
2638 {
2639 enemy *e = new eScript(x,y,new_id,clk);
2640 guys.add(e);
2641 e->x = x;
2642 e->y = y;
2643 break;
2644 }
2645
2646
2647 case eeFFRIENDLY01:
2648 case eeFFRIENDLY02:
2649 case eeFFRIENDLY03:
2650 case eeFFRIENDLY04:
2651 case eeFFRIENDLY05:
2652 case eeFFRIENDLY06:
2653 case eeFFRIENDLY07:
2654 case eeFFRIENDLY08:
2655 case eeFFRIENDLY09:
2656 case eeFFRIENDLY10:
2657 {
2658 enemy *e = new eFriendly(x,y,new_id,clk);
2659 guys.add(e);
2660 e->x = x;
2661 e->y = y;
2662 break;
2663 }
2664
2665
2666 default: break;
2667 }
2668
2669 // add segments of segmented enemies
2670 int32_t c=0;
2671
2672 switch(guysbuf[new_id&0xFFF].type)
2673 {
2674 case eeMOLD:
2675 {
2676 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
2677 new_id &= 0xFFF;
2678
2679 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[new_id].attributes[0])); i++)
2680 {
2681 //christ this is messy -DD
2682 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[new_id&0xFFF].step*100))));
2683
2684 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,new_id+0x1000,segclk)))
2685 {
2686 al_trace("Moldorm segment %d could not be created!\n",i+1);
2687
2688 for(int32_t j=0; j<i+1; j++)
2689 guys.del(guys.Count()-1);
2690
2691 return 0;
2692 }
2693
2694 if(i>0)
2695 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
2696
2697
2698 }
2699
2700 break;
2701 }
2702
2703 case eeLANM:
2704 {
2705 new_id &= 0xFFF;
2706 int32_t shft = guysbuf[new_id].attributes[1];
2707 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
2708 enemy *e = new esLanmola((zfix)x,(zfix)y,new_id+0x1000,0);
2709
2710 if(!guys.add(e))
2711 {
2712 al_trace("Lanmola segment 1 could not be created!\n");
2713 guys.del(guys.Count()-1);
2714 return 0;
2715 }
2716 e->x = x;
2717 e->y = y;
2718
2719
2720
2721 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[new_id&0xFFF].attributes[0])); i++)
2722 {
2723 enemy *e2 = new esLanmola((zfix)x,(zfix)y,new_id+0x2000,-(i<<shft));
2724 if(!guys.add(e2))
2725 {
2726 al_trace("Lanmola segment %d could not be created!\n",i+1);
2727
2728 for(int32_t j=0; j<i+1; j++)
2729 guys.del(guys.Count()-1);
2730
2731 return 0;
2732 }
2733 e2->x = x;
2734 e2->y = y;
2735
2736 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
2737
2738 }
2739 }
2740 break;
2741
2742 case eeMANHAN:
2743 new_id &= 0xFFF;
2744
2745 for(int32_t i=0; i<((!(guysbuf[new_id].attributes[1]))?4:8); i++)
2746 {
2747 if(!guys.add(new esManhandla((zfix)x,(zfix)y,new_id+0x1000,i)))
2748 {
2749 al_trace("Manhandla head %d could not be created!\n",i+1);
2750
2751 for(int32_t j=0; j<i+1; j++)
2752 {
2753 guys.del(guys.Count()-1);
2754 }
2755
2756 return 0;
2757 }
2758
2759
2760 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[new_id].attributes[0];
2761 }
2762
2763 break;
2764
2765 case eeGLEEOK:
2766 {
2767 /*
2768 new_id &= 0xFFF;
2769 int32_t head_cnt = zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].attributes[0]));
2770 Z_scripterrlog("Gleeok head count is %d\n",head_cnt);
2771 for(int32_t i=0; i<head_cnt; i++)
2772 {
2773 //enemy *e = new esGleeok(x,y,new_id+0x1000,clk,gleeok);
2774 if(!guys.add(new esGleeok((zfix)x,(zfix)y,new_id+0x1000,c, gleeok)))
2775 {
2776 al_trace("Gleeok head %d could not be created!\n",i+1);
2777
2778 for(int32_t j=0; j<i+1; j++)
2779 {
2780 guys.del(guys.Count()-1);
2781 }
2782
2783 break;
2784 }
2785
2786 c-=guysbuf[new_id].misc4;
2787 */
2788
2789 // }
2790 }
2791 break;
2792
2793
2794 case eePATRA:
2795 {
2796 new_id &= 0xFFF;
2797 int32_t outeyes = 0;
2798 ptra = new ePatraBS((zfix)x,(zfix)y,id,clk);
2799
2800 for(int32_t i=0; i<zc_min(254,guysbuf[new_id&0xFFF].attributes[0]); i++)
2801 {
2802 if(!((guysbuf[new_id].attributes[9] &&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,new_id+0x1000,i,ptra)):guys.add(new esPatra((zfix)x,(zfix)y,new_id+0x1000,i,ptra))))
2803 {
2804 al_trace("Patra outer eye %d could not be created!\n",i+1);
2805
2806 for(int32_t j=0; j<i+1; j++)
2807 guys.del(guys.Count()-1);
2808
2809 return 0;
2810 }
2811 else
2812 outeyes++;
2813
2814
2815 }
2816
2817 for(int32_t i=0; i<zc_min(254,guysbuf[new_id&0xFFF].attributes[1]); i++)
2818 {
2819 if(!guys.add(new esPatra((zfix)x,(zfix)y,new_id+0x1000,i,ptra)))
2820 {
2821 al_trace("Patra inner eye %d could not be created!\n",i+1);
2822
2823 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
2824 guys.del(guys.Count()-1);
2825
2826 return 0;
2827 }
2828
2829
2830 }
2831 delete ptra;
2832 break;
2833 }
2834 }
2835
2836
2837 // TODO(crash): check that the above .add succeeded.
2838 ((enemy*)guys.spr(guys.Count()-1))->count_enemy = true;
2839 ((enemy*)guys.spr(guys.Count()-1))->stunclk = delay_timer;
2840 ((enemy*)guys.spr(guys.Count()-1))->dir = this->dir;
2841 ((enemy*)guys.spr(guys.Count()-1))->scale = this->scale;
2842 ((enemy*)guys.spr(guys.Count()-1))->angular = this->angular;
2843 ((enemy*)guys.spr(guys.Count()-1))->angle = this->angle;
2844 ((enemy*)guys.spr(guys.Count()-1))->rotation = this->rotation;
2845 ((enemy*)guys.spr(guys.Count()-1))->itemguy = this->itemguy;
2846 ((enemy*)guys.spr(guys.Count()-1))->leader = this->leader;
2847 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2848 ((enemy*)guys.spr(guys.Count()-1))->script_spawned = this->script_spawned;
2849 ((enemy*)guys.spr(guys.Count()-1))->sclk = 0;
2850
2851
2852 item_set = 0; //Do not make a drop.
2853
2854 switch(effect_type)
2855 {
2856 case -7:
2857 {
2858 weapon *w = new weapon(x,y-fakez,z,wBomb,0,wdp,0,-1,getUID(),false, 0);
2859 Lwpns.add(w);
2860 break;
2861 }
2862 case -6:
2863 {
2864 weapon *w = new weapon(x,y-fakez,z,wSBomb,0,wdp,0,-1,getUID(),false, 0);
2865 Lwpns.add(w);
2866 break;
2867 }
2868 case -5:
2869 {
2870 weapon *w = new weapon(x,y-fakez,z,wBomb,effect_type,0,0,Hero.getUID(), txsz, tysz);
2871 Lwpns.add(w);
2872 break;
2873 }
2874 case -4:
2875 {
2876 weapon *w = new weapon(x,y-fakez,z,wSBomb,effect_type,0,0,Hero.getUID(), txsz, tysz);
2877 Lwpns.add(w);
2878 break;
2879 }
2880 case -3: explode(1); break;
2881 case -2: explode(2); break;
2882 case -1: explode(0); break;
2883 case 0: break;
2884
2885 default:
2886 {
2887 //Dummy weapon function
2888 if ( effect_type > 255 ) effect_type = 0; //Sanity bound the sprite ID.
2889 weapon *w = new weapon(x,y-fakez,z,wSSparkle,effect_type,0,0,Hero.getUID(), txsz, tysz,0,0,0,0,0,0,0);
2890 Lwpns.add(w);
2891 break;
2892 }
2893 }
2894
2895
2896 yofs = -32768;
2897 switch(guysbuf[new_id&0xFFF].type)
2898 {
2899 case eeGLEEOK:
2900 {
2901 Z_scripterrlog("Replacing a gleeok.\n");
2902 enemy *tempenemy = (enemy *) guys.getByUID(parentCore);
2903 hp = -999;
2904 if (tempenemy) tempenemy->hp = -999;
2905 break;
2906
2907 }
2908 default:
2909 hp = -1000; break;
2910 }
2911 int mi = mapind(cur_map, screen_spawned);
2912 ++game->guys[mi];
2913 return 1;
2914
2915 }
2916 case edSPLIT:
2917 {
2918 for ( int32_t q = 0; q < dmisc4; q++ )
2919 {
2920 addenemy(screen_spawned,x,y,
2921 dmisc3+0x1000,-15);
2922
2923 }
2924 item_set = 0; //Do not make a drop.
2925 hp = -1000;
2926 return -1;
2927
2928 }
2929 case edSUMMON:
2930 {
2931 int32_t summon_count = zc::math::SafeMod(zc_oldrand(), dmisc4) + 1;
2932 for ( int32_t q = 0; q < summon_count; q++ )
2933 {
2934 int32_t x2=16*((zc_oldrand()%12)+2);
2935 int32_t y2=16*((zc_oldrand()%7)+2);
2936 addenemy(screen_spawned,
2937 //(x+(txsz*16)/2),(y+(tysz*16)/2)
2938 x2,y2,
2939 dmisc3+0x1000,-15);
2940
2941 }
2942 sfx(get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(x));
2943 return -1;
2944
2945 }
2946
2947 case edEXPLODESMALL:
2948 {
2949 weapon *ew=new weapon(x,y-fakez,z, ewBomb, 0, dmisc4, dir,-1,getUID(),false);
2950 Ewpns.add(ew);
2951 item_set = 0; //Should we make a drop?
2952 hp = -1000;
2953 return -1;
2954 }
2955
2956
2957 case edEXPLODEHARMLESS:
2958 {
2959 weapon *ew=new weapon(x,y-fakez,z, ewSBomb, 0, dmisc4, dir,-1,getUID(),false);
2960 Ewpns.add(ew);
2961 ew->hyofs = -32768;
2962 item_set = 0; //Should we make a drop?
2963 hp = -1000;
2964 return -1;
2965 }
2966
2967
2968 case edEXPLODELARGE:
2969 {
2970 weapon *ew=new weapon(x,y-fakez,z, ewSBomb, 0, dmisc4, dir,-1,getUID(),false);
2971 Ewpns.add(ew);
2972
2973 hp = -1000;
2974 return -1;
2975 }
2976
2977
2978 case edTRIGGERSECRETS:
2979 {
2980 trigger_secrets_for_screen(TriggerSource::Unspecified, screen_spawned, false);
2981 return -1;
2982 }
2983
2984 case edSTUNORCHINK:
2985
2/2
✓ Branch 0 taken 649 times.
✓ Branch 1 taken 1526 times.
2175 if(*power <= 0)
2986 {
2987 649 sfx(WAV_CHINK,pan(x));
2988 649 return 1;
2989 }
2990
2/2
✓ Branch 0 taken 407 times.
✓ Branch 1 taken 1119 times.
2645 if (stunclk)
2991 {
2992
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1119 times.
1119 if(get_qr(qr_NO_STUNLOCK_IGNORE))
2993 return 0;
2994
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1119 times.
1119 if(get_qr(qr_NO_STUNLOCK_BLOCK))
2995 {
2996 sfx(WAV_CHINK,pan(x));
2997 return 1;
2998 }
2999 1119 }
3000 [[fallthrough]];
3001
3002 case edSTUNORIGNORE:
3003
2/2
✓ Branch 0 taken 959 times.
✓ Branch 1 taken 2502 times.
3461 if(*power <= 0)
3004 959 return 0;
3005
2/2
✓ Branch 0 taken 550 times.
✓ Branch 1 taken 1952 times.
4454 if (stunclk)
3006 {
3007
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1952 times.
1952 if(get_qr(qr_NO_STUNLOCK_IGNORE))
3008 return 0;
3009
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1952 times.
1952 if(get_qr(qr_NO_STUNLOCK_BLOCK))
3010 {
3011 sfx(WAV_CHINK,pan(x));
3012 return 1;
3013 }
3014 1952 }
3015 [[fallthrough]];
3016
3017 case edSTUNONLY:
3018
7/10
✓ Branch 0 taken 4460 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4460 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4460 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3913 times.
✓ Branch 7 taken 547 times.
✓ Branch 8 taken 4139 times.
✓ Branch 9 taken 321 times.
4460 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wHookshot || wpnId==wSword) && stunclk>=159)
3019 {
3020 // Z_message("enemy::defend(), edSTUNONLY found a weapon of type FIRE, BOMB, SBOMB, HOOKSHOT, or SWORD:, with wpnId: \n", wpnId);
3021 321 return 1;
3022 }
3023
2/2
✓ Branch 0 taken 941 times.
✓ Branch 1 taken 3198 times.
4139 if (stunclk)
3024 {
3025
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3198 times.
3198 if(get_qr(qr_NO_STUNLOCK_IGNORE))
3026 return 0;
3027
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3198 times.
3198 if(get_qr(qr_NO_STUNLOCK_BLOCK))
3028 {
3029 sfx(WAV_CHINK,pan(x));
3030 return 1;
3031 }
3032 3198 }
3033 4139 stunclk=160;
3034 4139 sfx(WAV_EHIT,pan(x));
3035 4139 return 1;
3036
3037 case edCHINKL1:
3038 if(*power >= 1*game->get_hero_dmgmult()) break;
3039 [[fallthrough]];
3040 case edCHINKL2:
3041
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 61 times.
113 if(*power >= 2*game->get_hero_dmgmult()) break;
3042 [[fallthrough]];
3043 case edCHINKL4:
3044
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 110 times.
190 if(*power >= 4*game->get_hero_dmgmult()) break;
3045 [[fallthrough]];
3046 case edCHINKL6:
3047
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(*power >= 6*game->get_hero_dmgmult()) break;
3048 [[fallthrough]];
3049 case edCHINKL8:
3050
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 111 times.
154 if(*power >= 8*game->get_hero_dmgmult()) break;
3051 [[fallthrough]];
3052 case edCHINKL10:
3053
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(*power >= 10*game->get_hero_dmgmult()) break;
3054 [[fallthrough]];
3055 case edCHINK:
3056 1074 sfx(WAV_CHINK,pan(x));
3057 1074 return 1;
3058
3059 case edIGNOREL1:
3060 if(*power > 0) break;
3061 [[fallthrough]];
3062
3063 case edIGNORE:
3064 22345 return 0;
3065
3066 case ed1HKO:
3067 525 *power = hp;
3068 525 return -3;
3069
3070 case ed2x:
3071 {
3072
1/2
✓ Branch 0 taken 497 times.
✗ Branch 1 not taken.
497 *power = zc_max(1,*power*2);
3073 //int32_t pow = *power;
3074 //*power = vbound((pow*2),0,214747);
3075 497 return -1;
3076 }
3077 case ed3x:
3078 {
3079
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 *power = zc_max(1,*power*3);
3080 //int32_t pow = *power;
3081 //*power = vbound((pow*3),0,214747);
3082 8 return -1;
3083 }
3084
3085 case ed4x:
3086 {
3087 *power = zc_max(1,*power*4);
3088 //int32_t pow = *power;
3089 //*power = vbound((pow*4),0,214747);
3090 return -1;
3091 }
3092
3093
3094 case edHEAL:
3095 { //Probably needs its own function, or routine in the damage functuon to heal if power is negative.
3096 //int32_t pow = *power;
3097 //*power = vbound((pow*-1),0,214747);
3098 //break;
3099
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 158 times.
158 *power = zc_min(0,*power*-1);
3100 158 return -1;
3101 }
3102 /*
3103 case edLEVELDAMAGE:
3104 {
3105 int32_t pow = *power;
3106 int32_t lvl = *level;
3107 *power = vbound((pow*lvl),0,214747);
3108 break;
3109 }
3110 case edLEVELREDUCTION:
3111 {
3112 int32_t pow = *power;
3113 int32_t lvl = *level;
3114 *power = vbound((pow/lvl),0,214747);
3115 break;
3116 }
3117 */
3118
3119 case edQUARTDAMAGE:
3120
2/2
✓ Branch 0 taken 178 times.
✓ Branch 1 taken 3 times.
181 *power = zc_max(1,*power/2);
3121
3122 [[fallthrough]];
3123 case edHALFDAMAGE:
3124
2/2
✓ Branch 0 taken 997 times.
✓ Branch 1 taken 191 times.
1188 *power = zc_max(1,*power/2);
3125 1188 break;
3126
3127 case edSWITCH:
3128 {
3129
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(Hero.switchhookclk) return 0; //Already switching!
3130
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 switch(type)
3131 {
3132 case eeAQUA: case eeMOLD: case eeDONGO: case eeMANHAN: case eeGLEEOK:
3133 case eeDIG: case eeGHOMA: case eeLANM: case eePATRA: case eeGANON:
3134 return 0;
3135 }
3136 4 hooked_comborpos = rpos_t::None;
3137 4 hooked_layerbits = 0;
3138 4 switching_object = this;
3139 4 switch_hooked = true;
3140 4 Hero.doSwitchHook(game->get_switchhookstyle());
3141
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(QMisc.miscsfx[sfxSWITCHED])
3142 sfx(QMisc.miscsfx[sfxSWITCHED],pan(x));
3143 4 return 1;
3144 }
3145
3146 case 0:
3147 {
3148
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96382 times.
96382 if(edef == edefSwitchHook)
3149 return -1;
3150
4/4
✓ Branch 0 taken 19592 times.
✓ Branch 1 taken 76790 times.
✓ Branch 2 taken 7811 times.
✓ Branch 3 taken 11781 times.
96382 if (stunclk && *power == 0)
3151 {
3152
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11781 times.
11781 if(get_qr(qr_NO_STUNLOCK_IGNORE))
3153 return 0;
3154
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 11755 times.
11781 if(get_qr(qr_NO_STUNLOCK_BLOCK))
3155 {
3156 26 sfx(WAV_CHINK,pan(x));
3157 26 return 1;
3158 }
3159 11755 }
3160 96356 break;
3161 }
3162 }
3163
3164 97719 return -1;
3165 135235 }
3166
3167 135235 int32_t enemy::defendNewInt(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable, weapon* w)
3168 {
3169
1/2
✓ Branch 0 taken 135235 times.
✗ Branch 1 not taken.
135235 int wuid = w?w->getUID():0;
3170
1/2
✓ Branch 0 taken 135235 times.
✗ Branch 1 not taken.
135235 bool fakeweap = (w && !Lwpns.getByUID(wuid));
3171
3172
1/2
✓ Branch 0 taken 135235 times.
✗ Branch 1 not taken.
135235 if(fakeweap)
3173 Lwpns.add(w);
3174 135235 std::vector<int32_t> &ev = FFCore.eventData;
3175 135235 ev.clear();
3176 135235 ev.push_back(*power*10000);
3177 135235 ev.push_back(edef*10000);
3178 135235 ev.push_back(unblockable*10000);
3179 135235 ev.push_back(wpnId*10000);
3180 135235 ev.push_back(0);
3181 135235 ev.push_back(getUID());
3182 135235 ev.push_back(wuid);
3183
3184 135235 throwGenScriptEvent(GENSCR_EVENT_ENEMY_HIT1);
3185 135235 *power = ev[0]/10000;
3186 135235 edef = ev[1]/10000;
3187 135235 unblockable = byte(ev[2]/10000);
3188 135235 wpnId = ev[3] / 10000;
3189 135235 bool nullify = ev[4]!=0;
3190 135235 ev.clear();
3191 135235 int ret = 0;
3192
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 135235 times.
135235 if(!nullify)
3193 {
3194 135235 ret = defendNew(wpnId, power, edef, unblockable);
3195
2/2
✓ Branch 0 taken 37690 times.
✓ Branch 1 taken 97545 times.
135235 if(ret < 0)
3196 {
3197 97545 ev.push_back(*power*10000);
3198 97545 ev.push_back(edef*10000);
3199 97545 ev.push_back(unblockable*10000);
3200 97545 ev.push_back(wpnId*10000);
3201 97545 ev.push_back(0);
3202 97545 ev.push_back(getUID());
3203
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97545 times.
97545 ev.push_back(w?w->getUID():0);
3204
3205 97545 throwGenScriptEvent(GENSCR_EVENT_ENEMY_HIT2);
3206 97545 *power = ev[0]/10000;
3207 97545 nullify = ev[4]!=0;
3208 97545 ev.clear();
3209 97545 }
3210 135235 }
3211
1/2
✓ Branch 0 taken 135235 times.
✗ Branch 1 not taken.
135235 if(fakeweap)
3212 Lwpns.remove(w);
3213
3214
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 135235 times.
135235 return nullify ? 0 : ret;
3215 }
3216
3217 108277 int32_t enemy::defenditemclassNew(int32_t wpnId, int32_t *power, weapon *w, weapon* realweap)
3218 {
3219
2/2
✓ Branch 0 taken 107700 times.
✓ Branch 1 taken 577 times.
108277 if(!realweap) realweap = w;
3220 108277 int32_t wid = getWeaponID(w);
3221
3222 108277 int32_t edef = resolveEnemyDefence(w);
3223
2/2
✓ Branch 0 taken 14862 times.
✓ Branch 1 taken 93415 times.
108277 if(QHeader.zelda_version > 0x250)
3224 14862 return defendNewInt(wid, power, edef, w->unblockable, realweap);
3225
2/3
✓ Branch 0 taken 993 times.
✓ Branch 1 taken 92422 times.
✗ Branch 2 not taken.
93415 switch(wid)
3226 {
3227 case wScript1: case wScript2: case wScript3: case wScript4: case wScript5:
3228 case wScript6: case wScript7: case wScript8: case wScript9: case wScript10:
3229 993 return defend(wpnId, power, edefSCRIPT);
3230
3231 case wWhistle:
3232 return -1;
3233
3234 default:
3235 92422 return defendNewInt(wid, power, edef, w->unblockable, realweap);
3236 }
3237 108277 }
3238
3239
3240 // Check defenses without actually acting on them.
3241 27402 bool enemy::candamage(int32_t power, int32_t edef, byte unblockable)
3242 {
3243
4/10
✓ Branch 0 taken 15409 times.
✓ Branch 1 taken 11050 times.
✓ Branch 2 taken 469 times.
✓ Branch 3 taken 474 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
27402 switch(defense[edef])
3244 {
3245 case edSTUNONLY:
3246 474 return false;
3247 case edSTUNORCHINK:
3248 case edCHINK:
3249 15409 return unblockable&WPNUNB_BLOCK;
3250 case edSTUNORIGNORE:
3251 case edIGNORE:
3252 11050 return unblockable&WPNUNB_IGNR;
3253
3254 case edIGNOREL1:
3255 return (unblockable&WPNUNB_IGNR) || power >= 1*game->get_hero_dmgmult();
3256 case edCHINKL1:
3257 return (unblockable&WPNUNB_BLOCK) || power >= 1*game->get_hero_dmgmult();
3258
3259 case edCHINKL2:
3260 return (unblockable&WPNUNB_BLOCK) || power >= 2*game->get_hero_dmgmult();
3261
3262 case edCHINKL4:
3263 return (unblockable&WPNUNB_BLOCK) || power >= 4*game->get_hero_dmgmult();
3264
3265 case edCHINKL6:
3266 return (unblockable&WPNUNB_BLOCK) || power >= 6*game->get_hero_dmgmult();
3267
3268 case edCHINKL8:
3269 return (unblockable&WPNUNB_BLOCK) || power >= 8*game->get_hero_dmgmult();
3270 }
3271
3272 469 return true;
3273 27402 }
3274
3275 // Do we do damage?
3276 // 0: takehit returns 0
3277 // 1: takehit returns 1
3278 // -1: do damage
3279 993 int32_t enemy::defend(int32_t wpnId, int32_t *power, int32_t edef)
3280 {
3281
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 993 times.
993 if(shieldCanBlock)
3282 {
3283 switch(defense[edef])
3284 {
3285 case edIGNORE:
3286 return 0;
3287 case edIGNOREL1:
3288 case edSTUNORIGNORE:
3289 if(*power <= 0)
3290 return 0;
3291 }
3292
3293 sfx(WAV_CHINK,pan(x));
3294 return 1;
3295 }
3296
3297
3/22
✓ Branch 0 taken 186 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 800 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 7 times.
993 switch(defense[edef])
3298 {
3299 case edSTUNORCHINK:
3300 if(*power <= 0)
3301 {
3302 sfx(WAV_CHINK,pan(x));
3303 return 1;
3304 }
3305
3306 [[fallthrough]];
3307 case edSTUNORIGNORE:
3308 if(*power <= 0)
3309 return 0;
3310
3311 [[fallthrough]];
3312 case edSTUNONLY:
3313 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wHookshot || wpnId==wSword) && stunclk>=159)
3314 return 1;
3315
3316 stunclk=160;
3317 sfx(WAV_EHIT,pan(x));
3318 return 1;
3319
3320 case edFREEZE:
3321 frozenclock=-1;
3322 //sfx(WAV_FREEZE,pan(x));
3323 return 1;
3324
3325 case edCHINKL1:
3326 if(*power >= 1*game->get_hero_dmgmult()) break;
3327 [[fallthrough]];
3328 case edCHINKL2:
3329 if(*power >= 2*game->get_hero_dmgmult()) break;
3330 [[fallthrough]];
3331 case edCHINKL4:
3332 if(*power >= 4*game->get_hero_dmgmult()) break;
3333 [[fallthrough]];
3334 case edCHINKL6:
3335 if(*power >= 6*game->get_hero_dmgmult()) break;
3336 [[fallthrough]];
3337 case edCHINKL8:
3338 if(*power >= 8*game->get_hero_dmgmult()) break;
3339 [[fallthrough]];
3340 case edCHINKL10:
3341 if(*power >= 10*game->get_hero_dmgmult()) break;
3342 [[fallthrough]];
3343 case edCHINK:
3344 sfx(WAV_CHINK,pan(x));
3345 return 1;
3346 case edTRIGGERSECRETS:
3347 trigger_secrets_for_screen(TriggerSource::Unspecified, screen_spawned, false);
3348 break;
3349
3350 case edIGNOREL1:
3351 if(*power > 0) break;
3352 [[fallthrough]];
3353 case edIGNORE:
3354 800 return 0;
3355
3356 case ed1HKO:
3357 *power = hp;
3358 return -3;
3359
3360 case ed2x:
3361 {
3362 *power = zc_max(1,*power*2);
3363 //int32_t pow = *power;
3364 //*power = vbound((pow*2),0,214747);
3365 return -1;
3366 }
3367 case ed3x:
3368 {
3369 *power = zc_max(1,*power*3);
3370 //int32_t pow = *power;
3371 //*power = vbound((pow*3),0,214747);
3372 return -1;
3373 }
3374
3375 case ed4x:
3376 {
3377 *power = zc_max(1,*power*4);
3378 //int32_t pow = *power;
3379 //*power = vbound((pow*4),0,214747);
3380 return -1;
3381 }
3382
3383
3384 case edHEAL:
3385 { //Probably needs its own function, or routine in the damage functuon to heal if power is negative.
3386 //int32_t pow = *power;
3387 //*power = vbound((pow*-1),0,214747);
3388 //break;
3389 *power = zc_min(0,*power*-1);
3390 return -1;
3391 }
3392 /*
3393 case edLEVELDAMAGE:
3394 {
3395 int32_t pow = *power;
3396 int32_t lvl = *level;
3397 *power = vbound((pow*lvl),0,214747);
3398 break;
3399 }
3400 case edLEVELREDUCTION:
3401 {
3402 int32_t pow = *power;
3403 int32_t lvl = *level;
3404 *power = vbound((pow/lvl),0,214747);
3405 break;
3406 }
3407 */
3408
3409
3410 case edQUARTDAMAGE:
3411
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 *power = zc_max(1,*power/2);
3412
3413 [[fallthrough]];
3414 case edHALFDAMAGE:
3415
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 *power = zc_max(1,*power/2);
3416 7 break;
3417 }
3418
3419 193 return -1;
3420 993 }
3421
3422 // Defend against a particular item class.
3423 int32_t enemy::defenditemclass(int32_t wpnId, int32_t *power)
3424 {
3425 int32_t def=-1;
3426
3427 switch(wpnId)
3428 {
3429 // These first 2 are only used by Gohma... enemy::takehit() has complicated stun-calculation code for these.
3430 case wBrang:
3431 def = defend(wpnId, power, edefBRANG);
3432 break;
3433
3434 case wHookshot:
3435 def = defend(wpnId, power, edefHOOKSHOT);
3436 break;
3437
3438 // Anyway...
3439 case wBomb:
3440 def = defend(wpnId, power, edefBOMB);
3441 break;
3442
3443 case wSBomb:
3444 def = defend(wpnId, power, edefSBOMB);
3445 break;
3446
3447 case wArrow:
3448 def = defend(wpnId, power, edefARROW);
3449 break;
3450
3451 case wFire:
3452 def = defend(wpnId, power, edefFIRE);
3453 break;
3454
3455 case wWand:
3456 def = defend(wpnId, power, edefWAND);
3457 break;
3458
3459 case wMagic:
3460 def = defend(wpnId, power, edefMAGIC);
3461 break;
3462
3463 case wHammer:
3464 def = defend(wpnId, power, edefHAMMER);
3465 break;
3466
3467 case wSword:
3468 def = defend(wpnId, power, edefSWORD);
3469 break;
3470
3471 case wBeam:
3472 def = defend(wpnId, power, edefBEAM);
3473 break;
3474
3475 case wRefBeam:
3476 def = defend(wpnId, power, edefREFBEAM);
3477 break;
3478
3479 case wRefMagic:
3480 def = defend(wpnId, power, edefREFMAGIC);
3481 break;
3482
3483 case wRefFireball:
3484 def = defend(wpnId, power, edefREFBALL);
3485 break;
3486
3487 case wRefRock:
3488 def = defend(wpnId, power, edefREFROCK);
3489 break;
3490
3491 case wStomp:
3492 def = defend(wpnId, power, edefSTOMP);
3493 break;
3494
3495 case wCByrna:
3496 def = defend(wpnId, power, edefBYRNA);
3497 break;
3498
3499 case wScript1:
3500 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT01);
3501 else def = defend(wpnId, power, edefSCRIPT);
3502 break;
3503
3504 case wScript2:
3505 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT02);
3506 else def = defend(wpnId, power, edefSCRIPT);
3507 break;
3508
3509 case wScript3:
3510 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT03);
3511 else def = defend(wpnId, power, edefSCRIPT);
3512 break;
3513
3514 case wScript4:
3515 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT04);
3516 else def = defend(wpnId, power, edefSCRIPT);
3517 break;
3518
3519 case wScript5:
3520 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT05);
3521 else def = defend(wpnId, power, edefSCRIPT);
3522 break;
3523
3524 case wScript6:
3525 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT06);
3526 else def = defend(wpnId, power, edefSCRIPT);
3527 break;
3528
3529 case wScript7:
3530 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT07);
3531 else def = defend(wpnId, power, edefSCRIPT);
3532 break;
3533
3534 case wScript8:
3535 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT08);
3536 else def = defend(wpnId, power, edefSCRIPT);
3537 break;
3538
3539 case wScript9:
3540 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT09);
3541 else def = defend(wpnId, power, edefSCRIPT);
3542 break;
3543
3544 case wScript10:
3545 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT10);
3546 else def = defend(wpnId, power, edefSCRIPT);
3547 break;
3548
3549 case wWhistle:
3550 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefWhistle);
3551 else break;
3552 break;
3553
3554 case wRefArrow:
3555 def = defend(wpnId, power, edefREFARROW);
3556 break;
3557 case wRefFire:
3558 def = defend(wpnId, power, edefREFFIRE);
3559 break;
3560 case wRefFire2:
3561 def = defend(wpnId, power, edefREFFIRE2);
3562 break;
3563
3564 //!ZoriaRPG : We need some special cases here, to ensure that old script defs don;t break.
3565 //Probably best to do this from the qest file, loading the values of Script(generic) into each
3566 //of the ten if the quest version is lower than N.
3567 //Either that, or we need a boolean flag to set int32_t he enemy editor, or by ZScript that changes this behaviour.
3568 //such as bool UseSeparatedScriptDefences. hah.
3569 default:
3570 //if(wpnId>=wScript1 && wpnId<=wScript10)
3571 // {
3572 // def = defend(wpnId, power, edefSCRIPT);
3573 // }
3574 // }
3575
3576 break;
3577 }
3578
3579 return def;
3580 }
3581
3582 // take damage or ignore it
3583 // 2 or -2: force wait a frame
3584 // < 0: damage (if any) dealt
3585 // > 0: blocked
3586 // 0: weapon passes through unhindered
3587 274677 int32_t enemy::takehit(weapon *w, weapon* realweap)
3588 {
3589
2/4
✓ Branch 0 taken 274677 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 274677 times.
274677 if(fallclk||drownclk) return 0;
3590
2/2
✓ Branch 0 taken 72352 times.
✓ Branch 1 taken 202325 times.
274677 if(!realweap) realweap = w;
3591 274677 int32_t wpnId = w->id;
3592 274677 int32_t power = w->power;
3593 274677 int32_t wpnx = w->x;
3594 274677 int32_t wpny = w->y;
3595 274677 int32_t enemyHitWeapon = w->parentitem;
3596 int32_t wpnDir;
3597 274677 int32_t parent_item = w->parentitem;
3598
3599
2/2
✓ Branch 0 taken 274562 times.
✓ Branch 1 taken 115 times.
274677 if ( w->useweapon > 0 /*&& wpnId != wWhistle*/ )
3600 {
3601 115 wpnId = w->useweapon;
3602 115 }
3603
3604 // If it's a boomerang that just bounced, use the opposite direction;
3605 // otherwise, it might bypass a shield. This probably won't handle
3606 // every case correctly, but it's better than having shields simply
3607 // not work against boomerangs.
3608
8/8
✓ Branch 0 taken 25236 times.
✓ Branch 1 taken 249441 times.
✓ Branch 2 taken 15681 times.
✓ Branch 3 taken 9555 times.
✓ Branch 4 taken 14419 times.
✓ Branch 5 taken 1262 times.
✓ Branch 6 taken 3308 times.
✓ Branch 7 taken 11111 times.
274677 if(w->id==wBrang && w->misc==1 && w->clk2>=256 && w->clk2<264)
3609 11111 wpnDir = oppositeDir[w->dir];
3610 else
3611 263566 wpnDir = w->dir;
3612
3613
5/8
✓ Branch 0 taken 274677 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 274677 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 274677 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 7320 times.
✓ Branch 7 taken 281997 times.
274677 if(dying || clk<0 || hclk>0 || superman)
3614 7320 return 0;
3615
3616 //Prevent boomerang from writing to hitby[] for more than one frame.
3617 //This also prevents stunlock.
3618 //if ( stunclk > 0 ) return 0;
3619 //this needs a rule for boomerangs that cannot stunlock!
3620 //further, bouncing weapons should probably SFX_CHINK and bounce here.
3621 //sigh.
3622
3623 281997 int32_t ret = -1;
3624
3625 // This obscure quest rule...
3626
5/6
✓ Branch 0 taken 101723 times.
✓ Branch 1 taken 180274 times.
✓ Branch 2 taken 98021 times.
✓ Branch 3 taken 3702 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 98021 times.
281997 if(get_qr(qr_BOMBDARKNUTFIX) && (wpnId==wBomb || wpnId==wSBomb))
3627 {
3628 double _MSVC2022_tmp1, _MSVC2022_tmp2;
3629 3702 double ddir=atan2_MSVC2022_FIX(double(wpny-y),double(x-wpnx));
3630 3702 wpnDir=zc_oldrand()&3;
3631
3632
4/4
✓ Branch 0 taken 493 times.
✓ Branch 1 taken 3209 times.
✓ Branch 2 taken 293 times.
✓ Branch 3 taken 200 times.
3702 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
3633 {
3634 200 wpnDir=down;
3635 200 }
3636
4/4
✓ Branch 0 taken 598 times.
✓ Branch 1 taken 2904 times.
✓ Branch 2 taken 293 times.
✓ Branch 3 taken 305 times.
3502 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
3637 {
3638 305 wpnDir=right;
3639 305 }
3640
4/4
✓ Branch 0 taken 2487 times.
✓ Branch 1 taken 710 times.
✓ Branch 2 taken 293 times.
✓ Branch 3 taken 2194 times.
3197 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
3641 {
3642 2194 wpnDir=up;
3643 2194 }
3644 else
3645 {
3646 1003 wpnDir=left;
3647 }
3648 3702 }
3649
3650 281997 int32_t xdir = dir;
3651 281997 shieldCanBlock=false;
3652
3653
4/4
✓ Branch 0 taken 270717 times.
✓ Branch 1 taken 11280 times.
✓ Branch 2 taken 2767 times.
✓ Branch 3 taken 267950 times.
282759 if(!(w->unblockable&WPNUNB_BLOCK)&&((wpnId==wHookshot && hitshield(wpnx, wpny, xdir))
3654
6/6
✓ Branch 0 taken 18734 times.
✓ Branch 1 taken 15967 times.
✓ Branch 2 taken 26888 times.
✓ Branch 3 taken 257029 times.
✓ Branch 4 taken 108 times.
✓ Branch 5 taken 256921 times.
270717 || ((flags&guy_shield_front && wpnDir==(xdir^down)) || (flags&guy_shield_back && wpnDir==(xdir^up)) ||
3655
4/4
✓ Branch 0 taken 1019 times.
✓ Branch 1 taken 255902 times.
✓ Branch 2 taken 762 times.
✓ Branch 3 taken 255140 times.
256921 (flags&guy_shield_left && wpnDir==(xdir^(xdir&2?right:left))) || (flags&guy_shield_right && wpnDir==(xdir^(dir&2?left:right)))))
3656 )
3657 // The hammer should already be dealt with by subclasses (Walker etc.)
3658 {
3659
10/10
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 380 times.
✓ Branch 2 taken 30 times.
✓ Branch 3 taken 757 times.
✓ Branch 4 taken 5961 times.
✓ Branch 5 taken 338 times.
✓ Branch 6 taken 43 times.
✓ Branch 7 taken 11 times.
✓ Branch 8 taken 169 times.
✓ Branch 9 taken 1490 times.
47511 switch(wpnId)
3660 {
3661 // Weapons which shields protect against
3662 case wSword:
3663 case wWand:
3664
2/2
✓ Branch 0 taken 5959 times.
✓ Branch 1 taken 2 times.
5963 if(Hero.getCharging()>0)
3665 2 Hero.setAttackClk(Hero.getAttackClk()+1); //Cancel charging
3666
3667 [[fallthrough]];
3668 case wHookshot:
3669 case wHSHandle:
3670 case wBrang:
3671 6341 shieldCanBlock=true;
3672 6679 break;
3673
3674 case wBeam:
3675 case wRefBeam:
3676 // Mirror shielded enemies!
3677 #if 0
3678 if(false /*flags&guy_mirror*/ && !get_qr(qr_SWORDMIRROR))
3679 {
3680 if(wpnId>wEnemyWeapons)
3681 return 0;
3682
3683 sfx(WAV_CHINK,pan(x));
3684 return 1;
3685 }
3686
3687 #endif
3688
3689 [[fallthrough]];
3690 case wRefRock:
3691 case wRefFireball:
3692 case wMagic:
3693 #if 0
3694 if(false /*flags&guy_mirror*/ && (wpnId!=wRefRock || get_qr(qr_REFLECTROCKS)))
3695 {
3696 sfx(WAV_CHINK,pan(x));
3697 return 3;
3698 }
3699
3700 #endif
3701
3702
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 368 times.
368 if(wpnId>wEnemyWeapons)
3703 return 0;
3704
3705 [[fallthrough]];
3706 case wArrow:
3707 411 case wRefArrow:
3708 default:
3709 1901 shieldCanBlock=true;
3710 1901 break;
3711
3712 // Bombs
3713 case wSBomb:
3714 case wBomb:
3715
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if (!get_qr(qr_TRUEFIXEDBOMBSHIELD)) goto hitclock;
3716 else if (!get_qr(qr_BOMBSPIERCESHIELD))
3717 {
3718 sfx(WAV_CHINK,pan(x));
3719 return 0;
3720 }
3721 else break;
3722
3723 // Weapons which ignore shields
3724 case wWhistle:
3725 case wHammer:
3726 169 break;
3727
3728 // Weapons which shouldn't be removed by shields
3729 case wLitBomb:
3730 case wLitSBomb:
3731 case wWind:
3732 case wPhantom:
3733 case wSSparkle:
3734 case wBait:
3735 864 return 0;
3736
3737 case wFire:
3738 case wRefFire:
3739 case wRefFire2:
3740 ;
3741 757 }
3742 9168 }
3743
3744
8/8
✓ Branch 0 taken 103856 times.
✓ Branch 1 taken 106603 times.
✓ Branch 2 taken 432 times.
✓ Branch 3 taken 270 times.
✓ Branch 4 taken 27419 times.
✓ Branch 5 taken 25184 times.
✓ Branch 6 taken 2767 times.
✓ Branch 7 taken 9057 times.
275588 switch(wpnId)
3745 {
3746 case wWhistle: //No longer completely ignore whistle weapons! -Z
3747 {
3748
3749
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 432 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
432 if ( ((itemsbuf[parent_item].flags & item_flag2) == 0) || ( parent_item == -1 ) ) //if the flag is set, or the weapon is scripted
3750 {
3751 432 return 0; break;
3752 }
3753 else
3754 {
3755 w->power = power = itemsbuf[parent_item].misc5;
3756
3757 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3758
3759 if(def <= 0)
3760 {
3761 hp -= power;
3762 return def;
3763 }
3764 break;
3765 }
3766 break;
3767 }
3768
3769 case wPhantom:
3770 270 return 0;
3771
3772 case wLitBomb:
3773 case wLitSBomb:
3774 case wBait:
3775 case wWind:
3776 case wSSparkle:
3777 103856 return 0;
3778
3779 case wFSparkle:
3780
3781 // Only take sparkle damage if the sparkle's parent item is not
3782 // defended against.
3783
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 27402 times.
27419 if(enemyHitWeapon > -1)
3784 {
3785 27402 int32_t p = 0;
3786 27402 int32_t f = itemsbuf[enemyHitWeapon].type;
3787
3788
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 27402 times.
27402 switch(f)
3789 {
3790 case itype_arrow:
3791 if(!candamage(p, edefARROW, w->unblockable)) return 0;
3792
3793 break;
3794
3795 case itype_cbyrna:
3796 if(!candamage(p, edefBYRNA, w->unblockable)) return 0;
3797
3798 break;
3799
3800 case itype_brang:
3801
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 26933 times.
27402 if(!candamage(p, edefBRANG, w->unblockable)) return 0;
3802
3803 469 break;
3804
3805 default:
3806 return 0;
3807 }
3808 469 }
3809
3810 486 wpnId = wSword;
3811 486 power = game->get_hero_dmgmult()>>1;
3812 486 goto fsparkle;
3813 break;
3814
3815 case wBrang:
3816 {
3817 //int32_t def = defendNew(wpnId, &power, edefBRANG, w);
3818 25184 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3819 //preventing stunlock might be best, here. -Z
3820
2/2
✓ Branch 0 taken 5585 times.
✓ Branch 1 taken 19599 times.
25184 if(def >= 0) return def;
3821 19599 ret = def;
3822
3823 // Not hurt by 0-damage weapons
3824
2/2
✓ Branch 0 taken 3217 times.
✓ Branch 1 taken 16382 times.
19599 if(!(flags & guy_bhit))
3825 {
3826 16382 stunclk=160;
3827
3828
3/4
✓ Branch 0 taken 16382 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1311 times.
✓ Branch 3 taken 15071 times.
16382 if(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))
3829 {
3830
1/2
✓ Branch 0 taken 1311 times.
✗ Branch 1 not taken.
1311 hp -= (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))*game->get_hero_dmgmult();
3831 1311 goto hitclock;
3832 }
3833
3834 15071 break;
3835 }
3836
3837
2/2
✓ Branch 0 taken 424 times.
✓ Branch 1 taken 2793 times.
3217 if(!power)
3838
1/2
✓ Branch 0 taken 2793 times.
✗ Branch 1 not taken.
2793 hp-=(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].level : current_item(itype_brang))*game->get_hero_dmgmult();
3839 else
3840 424 hp-=power;
3841
3842 3217 goto hitclock;
3843 }
3844
3845 case wHookshot:
3846 {
3847 //int32_t def = defendNew(wpnId, &power, edefHOOKSHOT,w);
3848 2767 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3849
3850
2/2
✓ Branch 0 taken 994 times.
✓ Branch 1 taken 1773 times.
2767 if(def >= 0) return def;
3851 1773 ret = def;
3852
3853
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1773 times.
1773 bool swgrab = switch_hooked || w->family_class == itype_switchhook;
3854
3/4
✓ Branch 0 taken 1773 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1625 times.
✓ Branch 3 taken 148 times.
1773 if(swgrab || !(flags & guy_bhit))
3855 {
3856
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1625 times.
1625 if(!swgrab)
3857 1625 stunclk=160;
3858
3859
3/4
✓ Branch 0 taken 1625 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 549 times.
✓ Branch 3 taken 1076 times.
1625 if(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot))
3860 {
3861
1/2
✓ Branch 0 taken 549 times.
✗ Branch 1 not taken.
549 hp -= (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot))*game->get_hero_dmgmult();
3862 549 goto hitclock;
3863 }
3864
3865 1076 break;
3866 }
3867
3868
3/4
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 103 times.
✓ Branch 2 taken 103 times.
✗ Branch 3 not taken.
148 if(!power) hp-=(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].level : current_item(itype_hookshot))*game->get_hero_dmgmult();
3869 else
3870 45 hp-=power;
3871
3872 148 goto hitclock;
3873 }
3874 break;
3875
3876 case wHSHandle:
3877 {
3878
3/4
✓ Branch 0 taken 9057 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 523 times.
✓ Branch 3 taken 8534 times.
9057 if(itemsbuf[enemyHitWeapon>-1 ? enemyHitWeapon : current_item_id(itype_hookshot)].flags & item_flag1)
3879 523 return 0;
3880
3881
3/4
✓ Branch 0 taken 6094 times.
✓ Branch 1 taken 2440 times.
✓ Branch 2 taken 2440 times.
✗ Branch 3 not taken.
8534 bool ignorehookshot = ((defense[edefHOOKSHOT] == edIGNORE) || ((defense[edefHOOKSHOT] == edIGNOREL1 || defense[edefHOOKSHOT] == edSTUNORIGNORE)
3882
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2440 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2440 && (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot)) <= 0));
3883
3884 // Peahats, Darknuts, Aquamentuses, Pols Voices, Wizzrobes, Manhandlas
3885
6/8
✓ Branch 0 taken 2788 times.
✓ Branch 1 taken 5746 times.
✓ Branch 2 taken 2788 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2788 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 502 times.
✓ Branch 7 taken 2286 times.
10246 if(!(type==eePEAHAT || type==eeAQUA || type==eeMANHAN || (type==eeWIZZ && !ignorehookshot)
3886
6/6
✓ Branch 0 taken 3375 times.
✓ Branch 1 taken 2873 times.
✓ Branch 2 taken 1771 times.
✓ Branch 3 taken 3890 times.
✓ Branch 4 taken 1712 times.
✓ Branch 5 taken 2178 times.
2788 || (type==eeWALK && dmisc9==e9tPOLSVOICE) || (type==eeWALK && flags&(guy_shield_back|guy_shield_front|guy_shield_left|guy_shield_right))))
3887 2178 return 0;
3888
3889 12102 power = game->get_hero_dmgmult();
3890 12588 }
3891
3892 fsparkle:
3893
3894 [[fallthrough]];
3895 default:
3896 // Work out the defenses!
3897 {
3898 107699 int32_t def = defenditemclassNew(wpnId, &power, w, realweap);
3899
3900
2/2
✓ Branch 0 taken 31754 times.
✓ Branch 1 taken 75945 times.
107699 if(def >= 0)
3901 31754 return def;
3902
2/2
✓ Branch 0 taken 75485 times.
✓ Branch 1 taken 460 times.
75945 else if(def == -3) // OHKO... doesn't 'hit' the weapon?
3903 460 ret = 0;
3904 }
3905
3906
2/2
✓ Branch 0 taken 75928 times.
✓ Branch 1 taken 17 times.
151875 if(!power)
3907 {
3908
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 15 times.
17 if(flags & guy_bhit)
3909 2 hp-=1;
3910 else
3911 {
3912 // Don't make a long chain of 'stun' hits
3913
5/8
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
✓ Branch 7 taken 11 times.
15 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wSword) && stunclk>0)
3914 4 return 1;
3915
3916
3917
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(!switch_hooked)
3918 11 stunclk=160;
3919 11 break;
3920 }
3921 2 }
3922 75928 else hp-=power;
3923
3924 hitclock:
3925 81166 hclk=33;
3926
3927 // Use w->dir instead of wpnDir to make sure boomerangs don't push enemies the wrong way
3928
2/2
✓ Branch 0 taken 36106 times.
✓ Branch 1 taken 45060 times.
81166 if((dir&2)==(w->dir&2))
3929 {
3930 45060 sclk=(w->dir<<8)+16;
3931 45060 }
3932 81166 }
3933
3934
5/6
✓ Branch 0 taken 77725 times.
✓ Branch 1 taken 19599 times.
✓ Branch 2 taken 22015 times.
✓ Branch 3 taken 75309 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 22015 times.
97324 if(((wpnId==wBrang) || (get_qr(qr_NOFLASHDEATH))) && (hp<=0 && !immortal))
3935 {
3936 22015 fading=fade_blue_poof;
3937 22015 }
3938
3939
6/6
✓ Branch 0 taken 88602 times.
✓ Branch 1 taken 8722 times.
✓ Branch 2 taken 46937 times.
✓ Branch 3 taken 41665 times.
✓ Branch 4 taken 2347 times.
✓ Branch 5 taken 44590 times.
97324 if ( FFCore.getQuestHeaderInfo(vZelda) > 0x250 || ( FFCore.getQuestHeaderInfo(vZelda) == 0x250 && FFCore.getQuestHeaderInfo(vBuild) > 31 )) //2.53 Gamma 2 and later
3940 {
3941
1/2
✓ Branch 0 taken 11069 times.
✗ Branch 1 not taken.
11069 if( hitsfx > 0 ) //user-set hit sound.
3942 {
3943
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if (!dying) //don't play the hit sound on death! -Z
3944 11069 sfx(hitsfx, pan(x));
3945 11069 }
3946 else sfx(WAV_EHIT, pan(x)); //Don't play the hardcoded sound if the user sets a custom one.
3947 11069 }
3948 else //2.50.2 or earlier
3949 {
3950 86255 sfx(WAV_EHIT, pan(x));
3951 86255 sfx(hitsfx, pan(x));
3952 }
3953
2/2
✓ Branch 0 taken 97295 times.
✓ Branch 1 taken 29 times.
97324 if(type==eeGUY)
3954 29 sfx(WAV_EDEAD, pan(x));
3955
3956 // Penetrating weapons
3957
4/4
✓ Branch 0 taken 95310 times.
✓ Branch 1 taken 2014 times.
✓ Branch 2 taken 88404 times.
✓ Branch 3 taken 8920 times.
97324 if((wpnId==wArrow || wpnId==wBeam) && !cannotpenetrate())
3958 {
3959 8920 int32_t item=enemyHitWeapon;
3960
3961
2/2
✓ Branch 0 taken 1752 times.
✓ Branch 1 taken 7168 times.
8920 if(wpnId==wArrow)
3962 {
3963 //If we use an arrow type for the item's Weapon type, the flags differ, so we need to rely on the flags from an arrow class.
3964
5/6
✓ Branch 0 taken 1624 times.
✓ Branch 1 taken 128 times.
✓ Branch 2 taken 379 times.
✓ Branch 3 taken 1245 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 379 times.
1752 if(item>=0 && (itemsbuf[item].flags&item_flag1) && (itemsbuf[parent_item].type == itype_arrow))
3965 379 return 0;
3966
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1373 times.
1373 else if(get_qr(qr_ARROWS_ALWAYS_PENETRATE)) return 0;
3967 //if(item<0)
3968 else
3969 1373 item=current_item_id(itype_arrow);
3970 1373 }
3971
3972 else
3973 {
3974
3975 //If we use an swordbeam type for the item's Weapon type, the flags differ, so we need to rely on the flags from an arrow class.
3976
3/6
✓ Branch 0 taken 7150 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7150 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7168 if(item>=0 && (itemsbuf[item].flags&item_flag3) && (itemsbuf[parent_item].type == itype_sword))
3977 return 0;
3978
3979
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7168 times.
7168 else if(get_qr(qr_SWORDBEAMS_ALWAYS_PENETRATE)) return 0;
3980 else
3981 //if(item<0)
3982 7168 item=current_item_id(itype_sword);
3983 }
3984 8541 }
3985
3986 96945 return ret;
3987 278037 }
3988
3989 63955692 bool enemy::dont_draw() const
3990 {
3991
6/6
✓ Branch 0 taken 63491179 times.
✓ Branch 1 taken 464513 times.
✓ Branch 2 taken 63420272 times.
✓ Branch 3 taken 70907 times.
✓ Branch 4 taken 175068 times.
✓ Branch 5 taken 63316111 times.
63955692 if(fading==fade_invisible || (((flags&guy_blinking)||(fading==fade_flicker)) && (clk&1)))
3992 639581 return true;
3993
3994
2/2
✓ Branch 0 taken 1375509 times.
✓ Branch 1 taken 61940602 times.
63316111 if(flags&guy_invisible)
3995 1375509 return true;
3996
3997
3/4
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 61940170 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 432 times.
61940602 if(flags&guy_lens_only && !lensclk)
3998 return true;
3999
4000 61940602 return false;
4001 63955692 }
4002
4003 #define DRAW_NORMAL 2
4004 #define DRAW_CLOAKED 1
4005 #define DRAW_INVIS 0
4006 // base drawing function to be used by all derived classes instead of
4007 // sprite::draw()
4008 46383919 void enemy::draw(BITMAP *dest)
4009 {
4010 46383919 didScriptThisFrame = false; //Since there's no better place to put it
4011
6/6
✓ Branch 0 taken 45618787 times.
✓ Branch 1 taken 765132 times.
✓ Branch 2 taken 45536137 times.
✓ Branch 3 taken 82650 times.
✓ Branch 4 taken 317591 times.
✓ Branch 5 taken 45301196 times.
46383919 if(fading==fade_invisible || (((flags&guy_blinking)||(fading==fade_flicker)) && (clk&1)))
4012 1082723 return;
4013
2/2
✓ Branch 0 taken 2770966 times.
✓ Branch 1 taken 42530230 times.
45301196 if(flags&guy_invisible)
4014 2770966 return;
4015
4016 //We did the normal don't_draw stuff here so we can make exceptions; specifically the lens check (which should make enemies
4017 // be cloaked if they have "invisible displays as cloaked" checked.
4018
4019 42530230 byte canSee = DRAW_NORMAL;
4020 //Enemy specific stuff
4021
2/2
✓ Branch 0 taken 42529066 times.
✓ Branch 1 taken 1164 times.
42530230 if ( editorflags & ENEMY_FLAG1 )
4022 {
4023 1164 canSee = DRAW_INVIS;
4024
1/2
✓ Branch 0 taken 1164 times.
✗ Branch 1 not taken.
1164 if (editorflags & ENEMY_FLAG4) canSee = DRAW_CLOAKED;
4025
2/4
✓ Branch 0 taken 1164 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1164 times.
✗ Branch 3 not taken.
1164 if (dmisc13 >= 0 && (editorflags & ENEMY_FLAG2))
4026 {
4027 if (game->item[dmisc13])
4028 {
4029 canSee = DRAW_NORMAL;
4030 }
4031 //else if ( lensclk && getlensid.flags SHOWINVIS )
4032 //{
4033 //
4034 //}
4035 //else
4036 //{
4037 // if ( (editorflags & ENEMY_FLAG4) ) canSee = DRAW_CLOAKED;
4038 // //otherwisem invisible
4039 //}
4040 }
4041 1164 }
4042 //Room specific
4043 42530230 mapscr* scr = get_scr(screen_spawned);
4044
2/2
✓ Branch 0 taken 40359031 times.
✓ Branch 1 taken 2171199 times.
42530230 if (scr->flags3&fINVISROOM)
4045 {
4046
4/6
✓ Branch 0 taken 2171199 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 226004 times.
✓ Branch 3 taken 1945195 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 226004 times.
2397203 if (canSee == DRAW_NORMAL && !(current_item(itype_amulet)) &&
4047
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 226004 times.
226004 !((itemsbuf[Hero.getLastLensID()].flags & item_flag5) && lensclk) && type!=eeGANON) canSee = DRAW_CLOAKED;
4048 2171199 }
4049 //Lens check
4050
2/2
✓ Branch 0 taken 27537 times.
✓ Branch 1 taken 42502693 times.
42530230 if (lensclk)
4051 {
4052
2/2
✓ Branch 0 taken 27105 times.
✓ Branch 1 taken 432 times.
27537 if(flags&guy_lens_only)
4053 {
4054
1/2
✓ Branch 0 taken 432 times.
✗ Branch 1 not taken.
432 if (canSee == DRAW_INVIS) canSee = DRAW_NORMAL;
4055 432 }
4056 27537 }
4057 else
4058 {
4059
2/2
✓ Branch 0 taken 42429277 times.
✓ Branch 1 taken 73416 times.
42502693 if(flags&guy_lens_only)
4060 73416 canSee = DRAW_INVIS;
4061 }
4062
3/4
✓ Branch 0 taken 74580 times.
✓ Branch 1 taken 42455650 times.
✓ Branch 2 taken 74580 times.
✗ Branch 3 not taken.
42530230 if (canSee == DRAW_INVIS && (editorflags & ENEMY_FLAG4)) canSee = DRAW_CLOAKED;
4063
3/4
✓ Branch 0 taken 42229646 times.
✓ Branch 1 taken 300584 times.
✓ Branch 2 taken 42229646 times.
✗ Branch 3 not taken.
42530230 if (canSee == DRAW_NORMAL && (editorflags & ENEMY_FLAG16)) canSee = DRAW_CLOAKED;
4064
4065
2/2
✓ Branch 0 taken 42455650 times.
✓ Branch 1 taken 74580 times.
42530230 if (canSee == DRAW_INVIS)
4066 74580 return;
4067
4068
4/4
✓ Branch 0 taken 42452423 times.
✓ Branch 1 taken 3227 times.
✓ Branch 2 taken 1416 times.
✓ Branch 3 taken 42451007 times.
42455650 if(fallclk||drownclk)
4069 {
4070
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4643 times.
4643 if (canSee == DRAW_CLOAKED)
4071 {
4072 sprite::drawcloaked(dest);
4073 }
4074
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4643 times.
4643 else if (canSee == DRAW_NORMAL)
4075 {
4076 4643 sprite::draw(dest);
4077 4643 }
4078 4643 return;
4079 }
4080 42451007 int32_t cshold=cs;
4081
4082
2/2
✓ Branch 0 taken 945772 times.
✓ Branch 1 taken 41505235 times.
42451007 if(dying)
4083 {
4084
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 945772 times.
945772 if(clk2>=19)
4085 {
4086 if(!(clk2&2))
4087 {
4088 //if the enemy isn't totally invisible, or if it is, but Hero has the item needed to reveal it, draw it.
4089 if (canSee == DRAW_CLOAKED)
4090 {
4091 sprite::drawcloaked(dest);
4092 }
4093 else if (canSee == DRAW_NORMAL)
4094 {
4095 sprite::draw(dest);
4096 }
4097 }
4098 return;
4099 }
4100
4101 945772 flip = 0;
4102 945772 tile = wpnsbuf[spr_death].tile;
4103
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 945772 times.
945772 if ( do_animation )
4104 {
4105 945772 int32_t offs = 0;
4106
2/2
✓ Branch 0 taken 853112 times.
✓ Branch 1 taken 92660 times.
945772 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS))
4107 {
4108
2/2
✓ Branch 0 taken 89665 times.
✓ Branch 1 taken 2995 times.
92660 if(clk2 > 2)
4109 {
4110 2995 spr_death_anim_clk=0;
4111 2995 clk2=1;
4112
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 2978 times.
2995 if(hp > -1000)
4113 2978 death_sfx();
4114 2995 }
4115
4/4
✓ Branch 0 taken 66415 times.
✓ Branch 1 taken 26245 times.
✓ Branch 2 taken 1076 times.
✓ Branch 3 taken 65339 times.
92660 if(clk2==1 && spr_death_anim_clk>-1)
4116 {
4117 65339 ++clk2;
4118
2/2
✓ Branch 0 taken 2382 times.
✓ Branch 1 taken 62957 times.
65339 spr_death_anim_frm=(spr_death_anim_clk/zc_max(wpnsbuf[spr_death].speed,1));
4119
2/2
✓ Branch 0 taken 145 times.
✓ Branch 1 taken 65194 times.
65339 spr_death_anim_frm *= zc_max(1,txsz);
4120 65339 int32_t rows = TILEROW(tile+spr_death_anim_frm)-TILEROW(tile);
4121
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 65239 times.
65339 spr_death_anim_frm += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4122
6/6
✓ Branch 0 taken 2382 times.
✓ Branch 1 taken 62957 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 65337 times.
✓ Branch 4 taken 62370 times.
✓ Branch 5 taken 2969 times.
65339 if(++spr_death_anim_clk >= (zc_max(wpnsbuf[spr_death].speed,1) * zc_max(wpnsbuf[spr_death].frames,1)))
4123 {
4124 2969 spr_death_anim_clk=-1;
4125 2969 clk2=1;
4126 2969 }
4127 65339 }
4128 92660 tile += spr_death_anim_frm;
4129 92660 }
4130
2/2
✓ Branch 0 taken 315607 times.
✓ Branch 1 taken 537505 times.
853112 else if(BSZ)
4131 {
4132
2/2
✓ Branch 0 taken 248172 times.
✓ Branch 1 taken 67435 times.
315607 offs = zc_min((15-clk2)/3,4);
4133 315607 }
4134
4/4
✓ Branch 0 taken 358415 times.
✓ Branch 1 taken 179090 times.
✓ Branch 2 taken 179079 times.
✓ Branch 3 taken 179336 times.
537505 else if(clk2>6 && clk2<=12)
4135 {
4136 179336 offs = 1;
4137 179336 }
4138
4139
2/2
✓ Branch 0 taken 497279 times.
✓ Branch 1 taken 448493 times.
945772 if(offs)
4140 {
4141
2/2
✓ Branch 0 taken 450 times.
✓ Branch 1 taken 448043 times.
448493 offs *= zc_max(1,txsz);
4142 448493 int32_t rows = TILEROW(tile+offs)-TILEROW(tile);
4143
2/2
✓ Branch 0 taken 438 times.
✓ Branch 1 taken 448055 times.
448493 offs += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4144 448493 }
4145 945772 tile += offs;
4146 945772 }
4147
4148
6/6
✓ Branch 0 taken 853112 times.
✓ Branch 1 taken 92660 times.
✓ Branch 2 taken 537505 times.
✓ Branch 3 taken 315607 times.
✓ Branch 4 taken 189182 times.
✓ Branch 5 taken 348323 times.
945772 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading==fade_blue_poof)
4149 597449 cs = wpnsbuf[spr_death].csets&15;
4150 else
4151 348323 cs = (((clk2+5)>>1)&3)+6;
4152 945772 }
4153
3/4
✓ Branch 0 taken 1275681 times.
✓ Branch 1 taken 40229554 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1275681 times.
41505235 else if(hclk>0 && getCanFlicker())
4154 {
4155 1275681 cs = getFlashingCSet();
4156 1275681 }
4157 //draw every other frame for flickering enemies
4158
2/2
✓ Branch 0 taken 304540 times.
✓ Branch 1 taken 42146467 times.
42451007 if (is_hitflickerframe(false))
4159 {
4160
5/6
✓ Branch 0 taken 111978 times.
✓ Branch 1 taken 192562 times.
✓ Branch 2 taken 97 times.
✓ Branch 3 taken 111881 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 192659 times.
304540 int32_t temp_flicker_color = (hp > 0 || immortal) ? (flickercolor < 0 ? game->get_spriteflickercolor() : flickercolor) : 0;
4161
3/4
✓ Branch 0 taken 248031 times.
✓ Branch 1 taken 56509 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 248031 times.
304540 if (game->get_spriteflickercolor() || temp_flicker_color)
4162 {
4163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56509 times.
56509 sprite_flicker_transp_passes = (flickertransp < 0 ? game->get_spriteflickertransp() : flickertransp);
4164 56509 sprite_flicker_color = temp_flicker_color;
4165 56509 sprite::draw(dest);
4166 56509 }
4167 304540 }
4168 else
4169 {
4170
2/2
✓ Branch 0 taken 225162 times.
✓ Branch 1 taken 41921305 times.
42146467 if (canSee == DRAW_CLOAKED)
4171 {
4172 225162 sprite::drawcloaked(dest);
4173 225162 }
4174
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41921305 times.
41921305 else if (canSee == DRAW_NORMAL)
4175 {
4176
1/2
✓ Branch 0 taken 41921305 times.
✗ Branch 1 not taken.
41921305 if ( frozenclock < 0 )
4177 {
4178 if ( frozentile > 0 ) tile = frozentile;
4179 loadpalset(csBOSS,frozencset);
4180 }
4181 41921305 sprite::draw(dest);
4182 41921305 }
4183 }
4184 42451007 cs=cshold;
4185 46383919 }
4186
4187 //old zc bosses
4188 40956281 void enemy::drawzcboss(BITMAP *dest)
4189 {
4190 40956281 didScriptThisFrame = false; //Since there's no better place to put it
4191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40956281 times.
40956281 if(dont_draw())
4192 return;
4193
4194 40956281 int32_t cshold=cs;
4195
4196
2/2
✓ Branch 0 taken 784546 times.
✓ Branch 1 taken 40171735 times.
40956281 if(dying)
4197 {
4198
2/2
✓ Branch 0 taken 4248 times.
✓ Branch 1 taken 780298 times.
784546 if(clk2>=19)
4199 {
4200
2/2
✓ Branch 0 taken 2124 times.
✓ Branch 1 taken 2124 times.
4248 if(!(clk2&2))
4201 2124 sprite::drawzcboss(dest);
4202
4203 4248 return;
4204 }
4205
4206 780298 flip = 0;
4207 780298 tile = wpnsbuf[spr_death].tile;
4208
4209
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 780298 times.
780298 if ( do_animation )
4210 {
4211
2/2
✓ Branch 0 taken 775562 times.
✓ Branch 1 taken 4736 times.
780298 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS))
4212 {
4213
2/2
✓ Branch 0 taken 4724 times.
✓ Branch 1 taken 12 times.
4736 if(clk2 > 2)
4214 {
4215 12 spr_death_anim_clk=0;
4216 12 clk2=1;
4217
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(hp > -1000)
4218 12 death_sfx();
4219 12 }
4220
4/4
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 4351 times.
✓ Branch 2 taken 189 times.
✓ Branch 3 taken 196 times.
4736 if(clk2==1 && spr_death_anim_clk>-1)
4221 {
4222 196 ++clk2;
4223
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 196 times.
196 spr_death_anim_frm=(spr_death_anim_clk/zc_max(wpnsbuf[spr_death].speed,1));
4224
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 196 times.
196 spr_death_anim_frm *= zc_max(1,txsz);
4225 196 int32_t rows = TILEROW(tile+spr_death_anim_frm)-TILEROW(tile);
4226
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 196 times.
196 spr_death_anim_frm += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4227
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 196 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 196 times.
✓ Branch 4 taken 188 times.
✓ Branch 5 taken 8 times.
196 if(++spr_death_anim_clk >= (zc_max(wpnsbuf[spr_death].speed,1) * zc_max(wpnsbuf[spr_death].frames,1)))
4228 {
4229 8 spr_death_anim_clk=-1;
4230 8 clk2=1;
4231 8 }
4232 196 }
4233 4736 tile += spr_death_anim_frm;
4234 4736 }
4235
2/2
✓ Branch 0 taken 278586 times.
✓ Branch 1 taken 496976 times.
775562 else if(BSZ)
4236
2/2
✓ Branch 0 taken 219134 times.
✓ Branch 1 taken 59452 times.
278586 tile += zc_min((15-clk2)/3,4);
4237
4/4
✓ Branch 0 taken 331281 times.
✓ Branch 1 taken 165695 times.
✓ Branch 2 taken 165538 times.
✓ Branch 3 taken 165743 times.
496976 else if(clk2>6 && clk2<=12)
4238 165743 ++tile;
4239 780298 }
4240
4241
6/6
✓ Branch 0 taken 775562 times.
✓ Branch 1 taken 4736 times.
✓ Branch 2 taken 496976 times.
✓ Branch 3 taken 278586 times.
✓ Branch 4 taken 183872 times.
✓ Branch 5 taken 313104 times.
780298 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading==fade_blue_poof)
4242 467194 cs = wpnsbuf[spr_death].csets&15;
4243 else
4244 313104 cs = (((clk2+5)>>1)&3)+6;
4245 780298 }
4246
2/2
✓ Branch 0 taken 38957045 times.
✓ Branch 1 taken 1214690 times.
40171735 else if(hclk>0)
4247 {
4248 1214690 cs = getFlashingCSet();
4249 1214690 }
4250
4251 40952033 mapscr* scr = get_scr(screen_spawned);
4252
4253
3/4
✓ Branch 0 taken 2045619 times.
✓ Branch 1 taken 38906414 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7543 times.
40959576 if((scr->flags3&fINVISROOM) &&
4254
2/2
✓ Branch 0 taken 7543 times.
✓ Branch 1 taken 2038076 times.
2045619 !(current_item(itype_amulet)) &&
4255
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7543 times.
7543 !(get_qr(qr_LENSSEESENEMIES) &&
4256 7543 lensclk) && type!=eeGANON)
4257 {
4258 7543 sprite::drawcloaked(dest);
4259 7543 }
4260 else
4261 {
4262
2/2
✓ Branch 0 taken 23473 times.
✓ Branch 1 taken 40921017 times.
40944490 if (is_hitflickerframe(true))
4263 {
4264
4/6
✓ Branch 0 taken 885 times.
✓ Branch 1 taken 22588 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 885 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 22588 times.
23473 int32_t temp_flicker_color = (hp > 0 || immortal) ? (flickercolor < 0 ? game->get_spriteflickercolor() : flickercolor) : 0;
4265
1/2
✓ Branch 0 taken 23473 times.
✗ Branch 1 not taken.
23473 if (game->get_spriteflickercolor())
4266 {
4267 sprite_flicker_transp_passes = (flickertransp < 0 ? game->get_spriteflickertransp() : flickertransp);
4268 sprite_flicker_color = temp_flicker_color;
4269 sprite::drawzcboss(dest);
4270 }
4271 23473 }
4272 else
4273 40921017 sprite::drawzcboss(dest);
4274 }
4275
4276 40952033 cs=cshold;
4277 40956281 }
4278
4279
4280 // similar to the overblock function--can do up to a 32x32 sprite
4281 //will this play nicely with scripttile, solely using the modifications in sprite::draw()?
4282 323235 void enemy::drawblock(BITMAP *dest,int32_t mask)
4283 {
4284 323235 int32_t thold=tile;
4285 323235 int32_t t1=tile;
4286 323235 int32_t t2=tile+20;
4287 323235 int32_t t3=tile+1;
4288 323235 int32_t t4=tile+21;
4289
4290
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 323235 times.
323235 switch(mask)
4291 {
4292 case 1:
4293 enemy::drawzcboss(dest);
4294 break;
4295
4296 case 3:
4297 if(flip&2)
4298 zc_swap(t1,t2);
4299
4300 tile=t1;
4301 enemy::drawzcboss(dest);
4302 tile=t2;
4303 yofs+=16;
4304 enemy::drawzcboss(dest);
4305 yofs-=16;
4306 break;
4307
4308 case 5:
4309 t2=tile+1;
4310
4311 if(flip&1)
4312 zc_swap(t1,t2);
4313
4314 tile=t1;
4315 enemy::drawzcboss(dest);
4316 tile=t2;
4317 xofs+=16;
4318 enemy::drawzcboss(dest);
4319 xofs-=16;
4320 break;
4321
4322 case 15:
4323
2/2
✓ Branch 0 taken 316479 times.
✓ Branch 1 taken 6756 times.
323235 if(flip&1)
4324 {
4325 6756 zc_swap(t1,t3);
4326 6756 zc_swap(t2,t4);
4327 6756 }
4328
4329
1/2
✓ Branch 0 taken 323235 times.
✗ Branch 1 not taken.
323235 if(flip&2)
4330 {
4331 zc_swap(t1,t2);
4332 zc_swap(t3,t4);
4333 }
4334
4335 323235 tile=t1;
4336 323235 enemy::drawzcboss(dest);
4337 323235 tile=t2;
4338 323235 yofs+=16;
4339 323235 enemy::drawzcboss(dest);
4340 323235 yofs-=16;
4341 323235 tile=t3;
4342 323235 xofs+=16;
4343 323235 enemy::drawzcboss(dest);
4344 323235 tile=t4;
4345 323235 yofs+=16;
4346 323235 enemy::drawzcboss(dest);
4347 323235 xofs-=16;
4348 323235 yofs-=16;
4349 323235 break;
4350 }
4351
4352 323235 tile=thold;
4353 323235 }
4354
4355 22435586 bool enemy::can_drawshadow() const
4356 {
4357
4/4
✓ Branch 0 taken 20420496 times.
✓ Branch 1 taken 2015090 times.
✓ Branch 2 taken 526918 times.
✓ Branch 3 taken 19893578 times.
22435586 if(dont_draw() || isSideViewGravity())
4358 2542008 return false;
4359
4360
2/2
✓ Branch 0 taken 356303 times.
✓ Branch 1 taken 19537275 times.
19893578 if(dying)
4361 356303 return false;
4362
4363 19537275 mapscr* scr = get_scr(screen_spawned);
4364
4/4
✓ Branch 0 taken 1718249 times.
✓ Branch 1 taken 17819026 times.
✓ Branch 2 taken 347010 times.
✓ Branch 3 taken 19190265 times.
19537275 if(((scr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))||
4365 19537275 (darkroom))
4366 347010 return false;
4367
4368
6/6
✓ Branch 0 taken 17381648 times.
✓ Branch 1 taken 1808617 times.
✓ Branch 2 taken 17107109 times.
✓ Branch 3 taken 274539 times.
✓ Branch 4 taken 16507954 times.
✓ Branch 5 taken 599155 times.
19190265 if(z <= 0 && fakez <= 0 && enemycanfall(id, false))
4369 16507954 return false;
4370
4371
2/2
✓ Branch 0 taken 21605 times.
✓ Branch 1 taken 2660706 times.
2682311 if(shadow_overpit())
4372 21605 return false;
4373
4374 2660706 return true;
4375 22435586 }
4376 19059922 void enemy::drawshadow(BITMAP *dest, bool translucent)
4377 {
4378
2/2
✓ Branch 0 taken 17351358 times.
✓ Branch 1 taken 1708564 times.
19059922 if(!can_drawshadow())
4379 17351358 return;
4380
4/4
✓ Branch 0 taken 1109409 times.
✓ Branch 1 taken 599155 times.
✓ Branch 2 taken 847 times.
✓ Branch 3 taken 1108562 times.
1708564 if(enemycanfall(id, false) && shadowtile == 0)
4381 847 shadowtile = wpnsbuf[spr_shadow].tile;
4382
4383 1708564 sprite::drawshadow(dest,translucent);
4384 19059922 }
4385
4386 129181 void enemy::masked_draw(BITMAP *dest,int32_t mx,int32_t my,int32_t mw,int32_t mh)
4387 {
4388 129181 BITMAP *sub=create_sub_bitmap(dest,mx,my,mw,mh);
4389
4390
1/2
✓ Branch 0 taken 129181 times.
✗ Branch 1 not taken.
129181 if(sub!=NULL)
4391 {
4392 129181 xofs-=mx;
4393 129181 yofs-=my;
4394 129181 enemy::draw(sub);
4395 129181 xofs+=mx;
4396 129181 yofs+=my;
4397 129181 destroy_bitmap(sub);
4398 129181 }
4399 else
4400 enemy::draw(dest);
4401 129181 }
4402
4403 39 void enemy::init_size_flags()
4404 {
4405
3/6
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 39 times.
39 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; }
4406
4/6
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23 times.
✓ Branch 5 taken 16 times.
39 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
4407
3/4
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 37 times.
39 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
4408
3/4
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 37 times.
39 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
4409
3/4
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 23 times.
39 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
4410
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 28 times.
39 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
4411
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 28 times.
39 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
4412
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 2 times.
39 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
4413
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 2 times.
39 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
4414 {
4415 2 yofs = (int32_t)d->yofs;
4416
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset);
4417 2 }
4418
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 2 times.
39 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
4419 39 }
4420
4421 // override hit detection to check for invicibility, stunned, etc
4422 118330101 bool enemy::hit()
4423 {
4424
4/4
✓ Branch 0 taken 116852909 times.
✓ Branch 1 taken 1477192 times.
✓ Branch 2 taken 114667209 times.
✓ Branch 3 taken 2185700 times.
118330101 if(dying || hclk>0) return false;
4425 114667209 return sprite::hit();
4426 118330101 }
4427 730351 bool enemy::hit(sprite *s)
4428 {
4429
3/4
✓ Branch 0 taken 730351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 713374 times.
✓ Branch 3 taken 16977 times.
730351 if(!hit() || !s->hit()) return false;
4430 713374 return sprite::hit(s);
4431 730351 }
4432
4433 45797464 bool enemy::hit(int32_t tx,int32_t ty,int32_t tz,int32_t txsz2,int32_t tysz2,int32_t tzsz2)
4434 {
4435
2/2
✓ Branch 0 taken 4116804 times.
✓ Branch 1 taken 41680660 times.
45797464 if(!hit()) return false;
4436 41680660 return sprite::hit(tx,ty,tz,txsz2,tysz2,tzsz2);
4437 45797464 }
4438 78011 bool enemy::hit(int32_t tx,int32_t ty,int32_t txsz2,int32_t tysz2)
4439 {
4440
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 78011 times.
78011 if(!hit()) return false;
4441 78011 return sprite::hit(tx,ty,txsz2,tysz2);
4442 78011 }
4443
4444 14262185 bool enemy::hit(weapon *w)
4445 {
4446
2/2
✓ Branch 0 taken 1734411 times.
✓ Branch 1 taken 12527774 times.
14262185 if(!hit()) return false;
4447
4448
2/2
✓ Branch 0 taken 6647382 times.
✓ Branch 1 taken 5880392 times.
12527774 if (replay_version_check(0, 14))
4449 {
4450
4/6
✓ Branch 0 taken 6422331 times.
✓ Branch 1 taken 225051 times.
✓ Branch 2 taken 6422331 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6422331 times.
✗ Branch 5 not taken.
6647382 if(!w->scriptcoldet || w->fallclk || w->drownclk)
4451 225051 return false;
4452 6422331 return sprite::hit(w);
4453 }
4454 5880392 return w->hit(this);
4455 14262185 }
4456
4457 39141797 bool enemy::can_pitfall(bool checkspawning)
4458 {
4459
4/4
✓ Branch 0 taken 37562467 times.
✓ Branch 1 taken 1579330 times.
✓ Branch 2 taken 37541718 times.
✓ Branch 3 taken 1600079 times.
39141797 if((fading||isspawning)&&checkspawning) return false; //Don't fall during spawn.
4460
2/2
✓ Branch 0 taken 30861954 times.
✓ Branch 1 taken 6679764 times.
37541718 switch(guysbuf[id&0xFFF].type)
4461 {
4462 case eeAQUA:
4463 case eeDIG:
4464 case eeDONGO:
4465 case eeFAIRY:
4466 case eeGANON:
4467 case eeGHOMA:
4468 case eeGLEEOK:
4469 case eeGUY:
4470 case eeLANM:
4471 case eeMANHAN:
4472 case eeMOLD:
4473 case eeNONE:
4474 case eePATRA:
4475 case eeZORA:
4476 6679764 return false; //Disallowed types
4477 default:
4478 30861954 return true;
4479 }
4480 39141797 }
4481 //Handle death
4482 39022651 void enemy::try_death(bool force_kill)
4483 {
4484
8/8
✓ Branch 0 taken 38964550 times.
✓ Branch 1 taken 58101 times.
✓ Branch 2 taken 38964506 times.
✓ Branch 3 taken 44 times.
✓ Branch 4 taken 46559 times.
✓ Branch 5 taken 38917947 times.
✓ Branch 6 taken 1532 times.
✓ Branch 7 taken 45027 times.
39022651 if(!dying && (force_kill || (hp<=0 && !immortal)))
4485 {
4486 45071 std::vector<int32_t> &ev = FFCore.eventData;
4487 45071 ev.clear();
4488 45071 ev.push_back(10000);
4489 45071 ev.push_back(getUID());
4490
4491 45071 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DEATH);
4492 45071 bool isSaved = !ev[0];
4493 45071 ev.clear();
4494
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45071 times.
45071 if(isSaved) return;
4495
4496
4/4
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 45014 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 51 times.
45071 if (itemguy && get_screen_state(screen_spawned).item_state == ScreenItemState::CarriedByEnemy)
4497 {
4498
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 51 times.
109 for(int32_t i=0; i<items.Count(); i++)
4499 {
4500
4/4
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 51 times.
58 if(((item*)items.spr(i))->pickup&ipENEMY && screen_spawned == ((item*)items.spr(i))->screen_spawned)
4501 {
4502
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 10 times.
51 if (!get_qr(qr_BROKEN_ITEM_CARRYING))
4503 {
4504
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 3 times.
10 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
4505 {
4506 7 items.spr(i)->x = x+hxofs+(hit_width/2)-8;
4507 7 items.spr(i)->y = y+hyofs+(hit_height/2)-10-fakez;
4508 7 }
4509 else
4510 {
4511
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(extend >= 3)
4512 {
4513 items.spr(i)->x = x+(txsz-1)*8;
4514 items.spr(i)->y = y-2+(tysz-1)*8;
4515 }
4516 else
4517 {
4518 3 items.spr(i)->x = x;
4519 3 items.spr(i)->y = y - 2;
4520 }
4521 }
4522 10 items.spr(i)->z = z;
4523 10 items.spr(i)->fakez = fakez;
4524 10 }
4525 else
4526 {
4527 41 items.spr(i)->x = x;
4528 41 items.spr(i)->y = y - 2;
4529 }
4530 51 }
4531 58 }
4532 51 }
4533
4534 45071 dying=true;
4535
4536
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 45037 times.
45071 if(fading==fade_flash_die)
4537 34 clk2=19+18*4;
4538 else
4539 {
4540 45037 clk2 = BSZ ? 15 : 19;
4541
4542
2/2
✓ Branch 0 taken 21095 times.
✓ Branch 1 taken 23942 times.
45037 if(fading!=fade_blue_poof)
4543 23942 fading=0;
4544 }
4545
4546
2/2
✓ Branch 0 taken 45014 times.
✓ Branch 1 taken 57 times.
45071 if(itemguy)
4547 {
4548 57 screen_item_set_state(screen_spawned, ScreenItemState::None);
4549 57 item_set=0;
4550 57 }
4551
6/6
✓ Branch 0 taken 44017 times.
✓ Branch 1 taken 1054 times.
✓ Branch 2 taken 35248 times.
✓ Branch 3 taken 8769 times.
✓ Branch 4 taken 1489 times.
✓ Branch 5 taken 33759 times.
45071 if (screen_spawned < 128 && count_enemy && !script_spawned)
4552 33759 game->guys[mapind(cur_map, screen_spawned)] -= 1;
4553 45071 }
4554 39022651 }
4555
4556 // --==**==--
4557
4558 // Movement routines that can be used by derived classes as needed
4559
4560 // --==**==--
4561
4562 580449 void enemy::fix_coords(bool bound)
4563 {
4564
1/2
✓ Branch 0 taken 580449 times.
✗ Branch 1 not taken.
580449 if ((get_qr(qr_OUTOFBOUNDSENEMIES) ? 1 : 0) ^ ((editorflags&ENEMY_FLAG11)?1:0)) return;
4565
1/2
✓ Branch 0 taken 580449 times.
✗ Branch 1 not taken.
580449 if(moveflags & move_ignore_screenedge) bound = false;
4566
4567
2/2
✓ Branch 0 taken 85032 times.
✓ Branch 1 taken 495417 times.
580449 if(bound)
4568 {
4569 495417 int w = world_w;
4570 495417 int h = world_h;
4571
4572
1/2
✓ Branch 0 taken 495417 times.
✗ Branch 1 not taken.
495417 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
4573 {
4574
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 495415 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
495417 x=vbound(x, 0, (( guysbuf[id].SIZEflags&OVERRIDE_TILE_WIDTH && !isflier(id) ) ? (w-((txsz-1)*16)) : w-16));
4575
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 495415 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
495417 y=vbound(y, 0,(( guysbuf[id].SIZEflags&OVERRIDE_TILE_HEIGHT && !isflier(id) ) ? (h-((txsz-1)*16)) : h-16));
4576 495417 }
4577 else
4578 {
4579 x=vbound(x, 0, w-16);
4580 y=vbound(y, 0, h-16);
4581 }
4582 495417 }
4583
4584
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 580449 times.
580449 if(!OUTOFBOUNDS(id, x, y))
4585 {
4586 580449 do_fix(x, 16, true);
4587
2/2
✓ Branch 0 taken 1139 times.
✓ Branch 1 taken 579310 times.
580449 if(isSideViewGravity())
4588 1139 do_fix(y,8,true);
4589 579310 else do_fix(y,16,true);
4590 580449 }
4591 580449 }
4592 9316 bool enemy::cannotpenetrate()
4593 {
4594
4/4
✓ Branch 0 taken 9135 times.
✓ Branch 1 taken 181 times.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 9097 times.
9316 return (type == eeAQUA || type == eeMANHAN || type == eeGHOMA);
4595 }
4596
4597 562 bool enemy::canmove_old(int32_t ndir,zfix s,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
4598 {
4599 bool ok;
4600 562 int32_t dx = 0, dy = 0;
4601 562 int32_t sv = 8;
4602
4603 //Why is this here??? Why is it needed???
4604 562 s += 0.5; // Make the ints round; doesn't seem to cause any problems.
4605
4606
8/9
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 51 times.
✓ Branch 2 taken 47 times.
✓ Branch 3 taken 85 times.
✓ Branch 4 taken 94 times.
✓ Branch 5 taken 78 times.
✓ Branch 6 taken 57 times.
✓ Branch 7 taken 81 times.
✗ Branch 8 not taken.
562 switch(ndir)
4607 {
4608 case 8:
4609 case up:
4610
3/4
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
69 if(canfall(id) && isSideViewGravity())
4611 return false;
4612
4613 69 dy = dy1-s;
4614
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 69 times.
69 special = (special==spw_clipbottomright)?spw_none:special;
4615
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 69 times.
69 ok = !m_walkflag_old(x,y+dy,special, x, y) && !flyerblocked(x,y+dy, special);
4616 69 break;
4617
4618 case 12:
4619 case down:
4620
3/4
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 40 times.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
51 if(canfall(id) && isSideViewGravity())
4621 return false;
4622
4623 51 dy = dy2+s;
4624
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
51 ok = !m_walkflag_old(x,y+dy,special, x, y) && !flyerblocked(x,y+dy, special);
4625 51 break;
4626
4627 case 14:
4628 case left:
4629 47 dx = dx1-s;
4630 47 sv = ((isSideViewGravity())?7:8);
4631
2/4
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 47 times.
47 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
4632
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 45 times.
47 ok = !m_walkflag_old(x+dx,y+sv,special, x, y) && !flyerblocked(x+dx,y+8, special);
4633 47 break;
4634
4635 case 10:
4636 case right:
4637 85 dx = dx2+s;
4638 85 sv = ((isSideViewGravity())?7:8);
4639
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 79 times.
85 ok = !m_walkflag_old(x+dx,y+sv,special, x, y) && !flyerblocked(x+dx,y+8, special);
4640 85 break;
4641
4642 case 9:
4643 case r_up:
4644 94 dx = dx2+s;
4645 94 dy = dy1-s;
4646
3/4
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93 times.
✓ Branch 3 taken 1 times.
187 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4647
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
93 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4648 94 break;
4649
4650 case 11:
4651 case r_down:
4652 78 dx = dx2+s;
4653 78 dx = dy2+s;
4654
3/4
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 1 times.
155 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4655
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4656 78 break;
4657
4658 case 13:
4659 case l_down:
4660 57 dx = dx1-s;
4661 57 dy = dy2+s;
4662
3/4
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 55 times.
✗ Branch 3 not taken.
112 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4663
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4664 57 break;
4665
4666 case 15:
4667 case l_up:
4668 81 dx = dx1-s;
4669 81 dy = dy1-s;
4670
3/4
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
✓ Branch 3 taken 1 times.
161 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4671
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4672 81 break;
4673
4674 default:
4675 db=99;
4676 return true;
4677 }
4678
4679 562 return ok;
4680 562 }
4681
4682
4683
4684
4685 // returns true if next step is ok, false if there is something there
4686 7645239 bool enemy::canmove(int32_t ndir,zfix s,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2, bool kb)
4687 {
4688 7645239 bool ok = false; //initialise the var, son't just declare it
4689 7645239 int32_t dx = 0, dy = 0;
4690 7645239 int32_t sv = 8;
4691 7645239 int32_t tries = 2; int32_t try_x = 0; int32_t try_y = 0;
4692 //Why is this here??? Why is it needed???
4693 7645239 s += 0.5; // Make the ints round; doesn't seem to cause any problems.
4694
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7645239 times.
7645239 int32_t usexoffs = (SIZEflags&OVERRIDE_HIT_X_OFFSET) ? hxofs : 0;
4695
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7645239 times.
7645239 int32_t useyoffs = (SIZEflags&OVERRIDE_HIT_Y_OFFSET) ? hyofs : 0;
4696
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 7645155 times.
7645239 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH) ? hit_width : 16;
4697
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 7645155 times.
7645239 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT) ? hit_height : 16;
4698 7645239 bool offgrid = OFFGRID_ENEMY;
4699
2/2
✓ Branch 0 taken 7291 times.
✓ Branch 1 taken 7637948 times.
7645239 if(!offgrid)
4700 {
4701 //Enemies smaller than 1-tile must act as 1-tile large, if off-grid movement is disabled.
4702
1/2
✓ Branch 0 taken 7637948 times.
✗ Branch 1 not taken.
7637948 if(usehei<16)usehei=16;
4703
1/2
✓ Branch 0 taken 7637948 times.
✗ Branch 1 not taken.
7637948 if(usewid<16)usewid=16;
4704 7637948 }
4705
9/9
✓ Branch 0 taken 1384486 times.
✓ Branch 1 taken 1156763 times.
✓ Branch 2 taken 1279152 times.
✓ Branch 3 taken 1269730 times.
✓ Branch 4 taken 558497 times.
✓ Branch 5 taken 666174 times.
✓ Branch 6 taken 625432 times.
✓ Branch 7 taken 584251 times.
✓ Branch 8 taken 120754 times.
7645239 switch(ndir) //need to check every 8 pixels between two points
4706 {
4707 case 8:
4708 case up:
4709 {
4710
4/4
✓ Branch 0 taken 165069 times.
✓ Branch 1 taken 1219417 times.
✓ Branch 2 taken 164409 times.
✓ Branch 3 taken 660 times.
1384486 if(enemycanfall(id) && isSideViewGravity())
4711 660 return false;
4712
4713 1383826 dy = dy1-s;
4714
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 1383346 times.
1383826 special = (special==spw_clipbottomright)?spw_none:special;
4715 1383826 tries = usewid/(offgrid ? 8 : 16);
4716
4717
2/2
✓ Branch 0 taken 1168843 times.
✓ Branch 1 taken 1384476 times.
2553319 for ( ; tries > 0; --tries )
4718 {
4719
2/2
✓ Branch 0 taken 211888 times.
✓ Branch 1 taken 1172588 times.
1384476 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy,special, ndir, x+usexoffs+try_x, y+useyoffs, kb) && !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy, special,kb);
4720 1384476 try_x += (offgrid ? 8 : 16);
4721
2/2
✓ Branch 0 taken 1169493 times.
✓ Branch 1 taken 214983 times.
1384476 if (!ok) break;
4722 1169493 }
4723
2/2
✓ Branch 0 taken 1168843 times.
✓ Branch 1 taken 214983 times.
1383826 if(!ok) break;
4724
1/2
✓ Branch 0 taken 1168843 times.
✗ Branch 1 not taken.
1168843 if((usewid%16)>0) //Uneven width
4725 {
4726 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy,special, ndir, x+usexoffs+usewid-1, y+useyoffs, kb) && !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy, special,kb);
4727 }
4728 1168843 break;
4729 }
4730 case 12:
4731 case down:
4732 {
4733
4/4
✓ Branch 0 taken 194058 times.
✓ Branch 1 taken 962705 times.
✓ Branch 2 taken 193332 times.
✓ Branch 3 taken 726 times.
1156763 if(enemycanfall(id) && isSideViewGravity())
4734 726 return false;
4735
4736 1156037 dy = dy2+s;
4737 1156037 tries = usewid/(offgrid ? 8 : 16);
4738
2/2
✓ Branch 0 taken 935910 times.
✓ Branch 1 taken 1156821 times.
2092731 for ( ; tries > 0; --tries )
4739 {
4740
3/4
✓ Branch 0 taken 218891 times.
✓ Branch 1 taken 937930 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 937930 times.
1156821 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy,special, ndir, x+usexoffs+try_x, y+useyoffs, kb) && !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+zc_max(usehei-16,0), special,kb);
4741 1156821 try_x += (offgrid ? 8 : 16);
4742
2/2
✓ Branch 0 taken 936694 times.
✓ Branch 1 taken 220127 times.
1156821 if (!ok) break;
4743 936694 }
4744
2/2
✓ Branch 0 taken 935910 times.
✓ Branch 1 taken 220127 times.
1156037 if(!ok) break;
4745
1/2
✓ Branch 0 taken 935910 times.
✗ Branch 1 not taken.
935910 if((usewid%16)>0) //Uneven width
4746 {
4747 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy,special, ndir, x+usexoffs+usewid-1, y+useyoffs, kb) && !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+zc_max(usehei-16,0), special,kb);
4748 }
4749 935910 break;
4750 }
4751 case 14:
4752 case left:
4753 {
4754 1279152 dx = dx1-s;
4755 1279152 sv = ((isSideViewGravity())?7:0);
4756
4/4
✓ Branch 0 taken 1278529 times.
✓ Branch 1 taken 623 times.
✓ Branch 2 taken 1883 times.
✓ Branch 3 taken 1276646 times.
1279152 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
4757 1279152 tries = usehei/(offgrid ? 8 : 16);
4758
2/2
✓ Branch 0 taken 1069947 times.
✓ Branch 1 taken 1280069 times.
2350016 for ( ; tries > 0; --tries )
4759 {
4760
2/2
✓ Branch 0 taken 207643 times.
✓ Branch 1 taken 1072426 times.
1280069 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+try_y+sv,special, ndir, x+usexoffs, y+useyoffs+try_y, kb) && !flyerblocked(x+usexoffs+dx,y+8+useyoffs+try_y, special,kb);
4761 1280069 try_y += (offgrid ? 8 : 16);
4762
2/2
✓ Branch 0 taken 1070864 times.
✓ Branch 1 taken 209205 times.
1280069 if (!ok) break;
4763 1070864 }
4764
2/2
✓ Branch 0 taken 1069947 times.
✓ Branch 1 taken 209205 times.
1279152 if(!ok) break;
4765
1/2
✓ Branch 0 taken 1069947 times.
✗ Branch 1 not taken.
1069947 if((usehei%16)>0) //Uneven height
4766 {
4767 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+usehei-1+sv,special, ndir, x+usexoffs, y+useyoffs+usehei-1, kb) && !flyerblocked(x+usexoffs+dx,y+8+useyoffs+usehei-1, special,kb);
4768 }
4769 1069947 break;
4770 }
4771 case 10:
4772 case right:
4773 {
4774 1269730 dx = dx2+s;
4775 1269730 sv = ((isSideViewGravity())?7:0);
4776 1269730 tries = usehei/(offgrid ? 8 : 16);
4777
2/2
✓ Branch 0 taken 1073347 times.
✓ Branch 1 taken 1270624 times.
2343971 for ( ; tries > 0; --tries )
4778 {
4779
3/4
✓ Branch 0 taken 194718 times.
✓ Branch 1 taken 1075906 times.
✓ Branch 2 taken 1075906 times.
✗ Branch 3 not taken.
1270624 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+try_y+sv,special, ndir, x+usexoffs, y+useyoffs+try_y, kb) && !flyerblocked(x+usexoffs+dx+zc_max(usewid-16,0),y+8+useyoffs+try_y, special,kb);
4780 1270624 try_y += (offgrid ? 8 : 16);
4781
2/2
✓ Branch 0 taken 1074241 times.
✓ Branch 1 taken 196383 times.
1270624 if (!ok) break;
4782 1074241 }
4783
2/2
✓ Branch 0 taken 1073347 times.
✓ Branch 1 taken 196383 times.
1269730 if(!ok) break;
4784
2/2
✓ Branch 0 taken 1073327 times.
✓ Branch 1 taken 20 times.
1073347 if((usehei%16)>0) //Uneven height
4785 {
4786
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
20 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+usehei-1+sv,special, ndir, x+usexoffs, y+useyoffs+usehei-1, kb) && !flyerblocked(x+usexoffs+dx+zc_max(usewid-16,0),y+8+useyoffs+usehei-1, special,kb);
4787 20 }
4788 1073347 break;
4789 }
4790 case 9:
4791 case r_up:
4792 {
4793 558497 dx = dx2+s;
4794 558497 dy = dy1-s;
4795 558497 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4796 558497 sv = ((isSideViewGravity())?7:0);
4797
2/2
✓ Branch 0 taken 540655 times.
✓ Branch 1 taken 558497 times.
1099152 for ( ; tries_x > 0; --tries_x )
4798 {
4799 558497 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4800 558497 try_y = 0;
4801
2/2
✓ Branch 0 taken 540655 times.
✓ Branch 1 taken 558497 times.
1099152 for ( ; tries_y > 0; --tries_y )
4802 {
4803
4/4
✓ Branch 0 taken 550183 times.
✓ Branch 1 taken 8314 times.
✓ Branch 2 taken 544702 times.
✓ Branch 3 taken 5481 times.
1103199 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4804
2/2
✓ Branch 0 taken 2841 times.
✓ Branch 1 taken 541861 times.
544702 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4805 558497 try_y += (offgrid ? 8 : 16);
4806
2/2
✓ Branch 0 taken 540655 times.
✓ Branch 1 taken 17842 times.
558497 if (!ok) break;
4807 540655 }
4808
2/2
✓ Branch 0 taken 540655 times.
✓ Branch 1 taken 17842 times.
558497 if (!ok) break;
4809
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 540655 times.
540655 if((usehei%16)>0) //Uneven height
4810 {
4811 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4812 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4813 }
4814 540655 try_x += (offgrid ? 8 : 16);
4815 540655 }
4816
2/2
✓ Branch 0 taken 540655 times.
✓ Branch 1 taken 17842 times.
558497 if(!ok) break;
4817
1/2
✓ Branch 0 taken 540655 times.
✗ Branch 1 not taken.
540655 if((usewid%16)>0) //Uneven width
4818 {
4819 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4820 try_y = 0;
4821 for ( ; tries_y > 0; --tries_y )
4822 {
4823 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4824 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4825 try_y += (offgrid ? 8 : 16);
4826 if (!ok) break;
4827 }
4828 if (!ok) break;
4829 if((usehei%16)>0) //Uneven height
4830 {
4831 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4832 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4833 }
4834 }
4835 540655 break;
4836 }
4837 case 11:
4838 case r_down:
4839 {
4840 666174 dx = dx2+s;
4841 666174 dx = dy2+s;
4842 666174 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4843 //sv = ((isSideViewGravity())?7:0);
4844
2/2
✓ Branch 0 taken 650102 times.
✓ Branch 1 taken 666174 times.
1316276 for ( ; tries_x > 0; --tries_x )
4845 {
4846 666174 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4847 666174 try_y = 0;
4848
2/2
✓ Branch 0 taken 650102 times.
✓ Branch 1 taken 666174 times.
1316276 for ( ; tries_y > 0; --tries_y )
4849 {
4850
4/4
✓ Branch 0 taken 664663 times.
✓ Branch 1 taken 1511 times.
✓ Branch 2 taken 651762 times.
✓ Branch 3 taken 12901 times.
1317936 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4851
2/2
✓ Branch 0 taken 164 times.
✓ Branch 1 taken 651598 times.
651762 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4852 666174 try_y += (offgrid ? 8 : 16);
4853
2/2
✓ Branch 0 taken 650102 times.
✓ Branch 1 taken 16072 times.
666174 if (!ok) break;
4854 650102 }
4855
2/2
✓ Branch 0 taken 650102 times.
✓ Branch 1 taken 16072 times.
666174 if (!ok) break;
4856
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650102 times.
650102 if((usehei%16)>0) //Uneven height
4857 {
4858 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4859 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4860 }
4861 650102 try_x += (offgrid ? 8 : 16);
4862 650102 }
4863
2/2
✓ Branch 0 taken 650102 times.
✓ Branch 1 taken 16072 times.
666174 if(!ok) break;
4864
1/2
✓ Branch 0 taken 650102 times.
✗ Branch 1 not taken.
650102 if((usewid%16)>0) //Uneven width
4865 {
4866 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4867 try_y = 0;
4868 for ( ; tries_y > 0; --tries_y )
4869 {
4870 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4871 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4872 try_y += (offgrid ? 8 : 16);
4873 if (!ok) break;
4874 }
4875 if (!ok) break;
4876 if((usehei%16)>0) //Uneven height
4877 {
4878 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4879 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4880 }
4881 }
4882 650102 break;
4883 }
4884 case 13:
4885 case l_down:
4886 {
4887 625432 dx = dx1-s;
4888 625432 dy = dy2+s;
4889 625432 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4890 //sv = ((isSideViewGravity())?7:0);
4891
2/2
✓ Branch 0 taken 607605 times.
✓ Branch 1 taken 625432 times.
1233037 for ( ; tries_x > 0; --tries_x )
4892 {
4893 625432 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4894 625432 try_y = 0;
4895
2/2
✓ Branch 0 taken 607605 times.
✓ Branch 1 taken 625432 times.
1233037 for ( ; tries_y > 0; --tries_y )
4896 {
4897
4/4
✓ Branch 0 taken 613437 times.
✓ Branch 1 taken 11995 times.
✓ Branch 2 taken 609141 times.
✓ Branch 3 taken 4296 times.
1234573 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4898
2/2
✓ Branch 0 taken 1056 times.
✓ Branch 1 taken 608085 times.
609141 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4899 625432 try_y += (offgrid ? 8 : 16);
4900
2/2
✓ Branch 0 taken 607605 times.
✓ Branch 1 taken 17827 times.
625432 if (!ok) break;
4901 607605 }
4902
2/2
✓ Branch 0 taken 607605 times.
✓ Branch 1 taken 17827 times.
625432 if (!ok) break;
4903
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 607605 times.
607605 if((usehei%16)>0) //Uneven height
4904 {
4905 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4906 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4907 }
4908 607605 try_x += (offgrid ? 8 : 16);
4909 607605 }
4910
2/2
✓ Branch 0 taken 607605 times.
✓ Branch 1 taken 17827 times.
625432 if(!ok) break;
4911
1/2
✓ Branch 0 taken 607605 times.
✗ Branch 1 not taken.
607605 if((usewid%16)>0) //Uneven width
4912 {
4913 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4914 try_y = 0;
4915 for ( ; tries_y > 0; --tries_y )
4916 {
4917 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4918 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4919 try_y += (offgrid ? 8 : 16);
4920 if (!ok) break;
4921 }
4922 if (!ok) break;
4923 if((usehei%16)>0) //Uneven height
4924 {
4925 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4926 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4927 }
4928 }
4929 607605 break;
4930 }
4931 case 15:
4932 case l_up:
4933 {
4934 584251 dx = dx1-s;
4935 584251 dy = dy1-s;
4936 584251 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4937 584251 sv = ((isSideViewGravity())?7:0);
4938
2/2
✓ Branch 0 taken 567671 times.
✓ Branch 1 taken 584251 times.
1151922 for ( ; tries_x > 0; --tries_x )
4939 {
4940 584251 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4941 584251 try_y = 0;
4942
2/2
✓ Branch 0 taken 567671 times.
✓ Branch 1 taken 584251 times.
1151922 for ( ; tries_y > 0; --tries_y )
4943 {
4944
4/4
✓ Branch 0 taken 575555 times.
✓ Branch 1 taken 8696 times.
✓ Branch 2 taken 571553 times.
✓ Branch 3 taken 4002 times.
1155804 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4945
2/2
✓ Branch 0 taken 2807 times.
✓ Branch 1 taken 568746 times.
571553 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4946 584251 try_y += (offgrid ? 8 : 16);
4947
2/2
✓ Branch 0 taken 567671 times.
✓ Branch 1 taken 16580 times.
584251 if (!ok) break;
4948 567671 }
4949
2/2
✓ Branch 0 taken 567671 times.
✓ Branch 1 taken 16580 times.
584251 if (!ok) break;
4950
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 567671 times.
567671 if((usehei%16)>0) //Uneven height
4951 {
4952 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4953 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4954 }
4955 567671 try_x += (offgrid ? 8 : 16);
4956 567671 }
4957
2/2
✓ Branch 0 taken 567671 times.
✓ Branch 1 taken 16580 times.
584251 if(!ok) break;
4958
1/2
✓ Branch 0 taken 567671 times.
✗ Branch 1 not taken.
567671 if((usewid%16)>0) //Uneven width
4959 {
4960 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4961 try_y = 0;
4962 for ( ; tries_y > 0; --tries_y )
4963 {
4964 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4965 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4966 try_y += (offgrid ? 8 : 16);
4967 if (!ok) break;
4968 }
4969 if (!ok) break;
4970 if((usehei%16)>0) //Uneven height
4971 {
4972 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4973 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4974 }
4975 }
4976 567671 break;
4977 }
4978 default:
4979 120754 db=99;
4980 120754 return true;
4981 }
4982
4983 7523099 return ok;
4984 7645239 }
4985
4986
4987 4811826 bool enemy::canmove(int32_t ndir,zfix s,int32_t special, bool kb)
4988 {
4989
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 4811760 times.
4811826 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH) ? hit_width : 16;
4990
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 4811760 times.
4811826 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT) ? hit_height : 16;
4991
2/2
✓ Branch 0 taken 4811760 times.
✓ Branch 1 taken 66 times.
4811826 if (usewid % 16 != 0) usewid += (16 - (usewid%16));
4992
2/2
✓ Branch 0 taken 4811760 times.
✓ Branch 1 taken 66 times.
4811826 if (usehei % 16 != 0) usehei += (16 - (usehei%16));
4993 4811826 --usewid;
4994 4811826 --usehei;
4995 4811826 return canmove(ndir,s,special,0,-8,usewid,usehei,kb);
4996 }
4997
4998 1310489 bool enemy::canmove(int32_t ndir,int32_t special, bool kb)
4999 {
5000 1310489 bool dodongo_move=true; //yes, it's an ugly hack, but we're going to rewrite everything later anyway - DN
5001
5002
4/4
✓ Branch 0 taken 7284 times.
✓ Branch 1 taken 1303205 times.
✓ Branch 2 taken 5385 times.
✓ Branch 3 taken 1899 times.
1310489 if(special==spw_clipright&&ndir==right)
5003 {
5004 1899 dodongo_move=canmove(ndir,(zfix)1,special,0,-8,31,15,kb);
5005 1899 }
5006
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1310484 times.
1310489 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH) ? hit_width : 16;
5007
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1310484 times.
1310489 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT) ? hit_height : 16;
5008
1/2
✓ Branch 0 taken 1310489 times.
✗ Branch 1 not taken.
1310489 if (usewid % 16 != 0) usewid += (16 - (usewid%16));
5009
1/2
✓ Branch 0 taken 1310489 times.
✗ Branch 1 not taken.
1310489 if (usehei % 16 != 0) usehei += (16 - (usehei%16));
5010 1310489 --usewid;
5011 1310489 --usehei;
5012
2/2
✓ Branch 0 taken 760676 times.
✓ Branch 1 taken 549813 times.
1310489 return canmove(ndir,(zfix)1,special,0,-8,usewid,usehei,kb)&&dodongo_move;
5013 }
5014
5015 144373 bool enemy::canmove(int32_t ndir, bool kb)
5016 {
5017 144373 return canmove(ndir,(zfix)1,spw_none,0,-8,15,15,kb);
5018 }
5019
5020 // 8-directional
5021 562 void enemy::newdir_8_old(int32_t newrate,int32_t newhoming,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
5022 {
5023 562 int32_t ndir=0;
5024
5025 // can move straight, check if it wants to turn
5026
2/2
✓ Branch 0 taken 549 times.
✓ Branch 1 taken 13 times.
562 if(canmove_old(dir,step,special,dx1,dy1,dx2,dy2))
5027 {
5028
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 549 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
549 if(grumble && (zc_oldrand()&4)<grumble) //Homing
5029 {
5030 int32_t w = Lwpns.idFirst(wBait);
5031
5032 if(w>=0)
5033 {
5034 int32_t bx = Lwpns.spr(w)->x;
5035 int32_t by = Lwpns.spr(w)->y;
5036
5037 ndir = (bx<x) ? left : (bx!=x) ? right : 0;
5038
5039 if(abs(int32_t(y)-by)>14)
5040 {
5041 if(ndir>0) // Already left or right
5042 {
5043 // Making the diagonal directions
5044 ndir += (by<y) ? 2 : 4;
5045 }
5046 else
5047 {
5048 ndir = (by<y) ? up : down;
5049 }
5050 }
5051
5052 if(canmove(ndir,special,false))
5053 {
5054 dir=ndir;
5055 return;
5056 }
5057 }
5058 }
5059
5060 // Homing added.
5061
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 549 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
549 if(newhoming && (zc_oldrand()&255)<newhoming)
5062 {
5063 ndir = lined_up(8,true);
5064
5065 if(ndir>=0 && canmove(ndir,special,false))
5066 {
5067 dir=ndir;
5068 }
5069
5070 return;
5071 }
5072
5073 549 int32_t r=zc_oldrand();
5074
5075
2/4
✓ Branch 0 taken 549 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 549 times.
549 if(newrate>0 && !(r%newrate))
5076 {
5077 549 ndir = ((dir+((r&64)?-1:1))&7)+8;
5078 549 int32_t ndir2=((dir+((r&64)?1:-1))&7)+8;
5079
5080
2/2
✓ Branch 0 taken 525 times.
✓ Branch 1 taken 24 times.
549 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5081 525 dir=ndir;
5082
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 19 times.
24 else if(canmove(ndir2,step,special,dx1,dy1,dx2,dy2,false))
5083 19 dir=ndir2;
5084
5085
3/4
✓ Branch 0 taken 525 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 525 times.
✗ Branch 3 not taken.
549 if(dir==ndir && (newrate>=4)) // newrate>=4, otherwise movement is biased toward upper-left
5086 // due to numerous lost fractional components. -L
5087 {
5088 x.doFloor();
5089 y.doFloor();
5090 }
5091 549 }
5092
5093 549 return;
5094 }
5095
5096 // can't move straight, must turn
5097 13 int32_t i=0;
5098
5099
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 for(; i<32; i++) // Try random dir
5100 {
5101 20 ndir=(zc_oldrand()&7)+8;
5102
5103
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 13 times.
20 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5104 13 break;
5105 7 }
5106
5107
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(i==32)
5108 {
5109 for(ndir=8; ndir<16; ndir++)
5110 {
5111 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5112 goto ok;
5113 }
5114
5115 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5116 }
5117
5118 ok:
5119 13 dir=ndir;
5120 13 x.doFloor();
5121 13 y.doFloor();
5122 562 }
5123
5124 600279 void enemy::newdir_8(int32_t newrate,int32_t newhoming,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
5125 {
5126 600279 int32_t ndir=0;
5127
5128 // can move straight, check if it wants to turn
5129
2/2
✓ Branch 0 taken 566220 times.
✓ Branch 1 taken 34059 times.
600279 if(canmove(dir,step,special,dx1,dy1,dx2,dy2,false))
5130 {
5131
4/4
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 566013 times.
✓ Branch 2 taken 106 times.
✓ Branch 3 taken 101 times.
566220 if(grumble && (zc_oldrand()&4)<abs(grumble)) //Homing
5132 {
5133 101 int32_t i = Lwpns.idFirst(wBait);
5134
1/2
✓ Branch 0 taken 101 times.
✗ Branch 1 not taken.
101 if(i >= 0) //idfirst returns -1 if it can't find any
5135 {
5136 weapon *w = (weapon*)Lwpns.spr(i);
5137 if (get_qr(qr_FIND_CLOSEST_BAIT))
5138 {
5139 int32_t currentrange;
5140 if (distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0) currentrange = distance(x, y, w->x, w->y);
5141 else currentrange = -1;
5142 int curid = i;
5143 ++i; //increment beforehand cause we just checked the first bait weapon and all others must be after it. ...otherwise it wouldn't be the first. -Deedee
5144 for(; i<Lwpns.Count(); ++i)
5145 {
5146 weapon *lw = (weapon*)Lwpns.spr(i);
5147 if (lw->id == wBait && distance(x, y, lw->x, lw->y) < currentrange && (distance(x, y, lw->x, lw->y) < lw->misc2 || lw->misc2 == 0))
5148 {
5149 currentrange = distance(x, y, lw->x, lw->y);
5150 curid = i;
5151 }
5152 }
5153 i = curid;
5154 if (currentrange == -1) i = -1;
5155 }
5156 else
5157 {
5158 if (!(distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0)) i = -1;
5159 }
5160 if(i>=0)
5161 {
5162 int32_t bx = Lwpns.spr(i)->x;
5163 int32_t by = Lwpns.spr(i)->y;
5164
5165 ndir = (bx<x) ? left : (bx!=x) ? right : 0;
5166
5167 if(abs(int32_t(y)-by)>14)
5168 {
5169 if(ndir>0) // Already left or right
5170 {
5171 // Making the diagonal directions
5172 ndir += (by<y) ? 2 : 4;
5173 }
5174 else
5175 {
5176 ndir = (by<y) ? up : down;
5177 }
5178 }
5179 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & item_flag1)) ndir = oppositeDir[ndir];
5180 if(canmove(ndir,special,false))
5181 {
5182 dir=ndir;
5183 return;
5184 }
5185 }
5186 }
5187 101 }
5188
5189 // Homing added.
5190
4/4
✓ Branch 0 taken 29843 times.
✓ Branch 1 taken 536377 times.
✓ Branch 2 taken 15574 times.
✓ Branch 3 taken 14269 times.
566220 if(newhoming && (zc_oldrand()&255)<abs(newhoming))
5191 {
5192 14269 ndir = lined_up(8,true);
5193
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14269 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14269 if (newhoming < 0 && ndir >= 0) ndir = oppositeDir[ndir];
5194
4/4
✓ Branch 0 taken 9480 times.
✓ Branch 1 taken 4789 times.
✓ Branch 2 taken 3593 times.
✓ Branch 3 taken 5887 times.
14269 if(ndir>=0 && canmove(ndir,special,false))
5195 {
5196 5887 dir=ndir;
5197 5887 }
5198
5199 14269 return;
5200 }
5201
5202 551951 int32_t r=zc_oldrand();
5203
5204
4/4
✓ Branch 0 taken 347861 times.
✓ Branch 1 taken 204090 times.
✓ Branch 2 taken 183707 times.
✓ Branch 3 taken 164154 times.
551951 if(newrate>0 && !(r%newrate))
5205 {
5206 164154 ndir = ((dir+((r&64)?-1:1))&7)+8;
5207 164154 int32_t ndir2=((dir+((r&64)?1:-1))&7)+8;
5208
5209
2/2
✓ Branch 0 taken 158137 times.
✓ Branch 1 taken 6017 times.
164154 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5210 158137 dir=ndir;
5211
2/2
✓ Branch 0 taken 915 times.
✓ Branch 1 taken 5102 times.
6017 else if(canmove(ndir2,step,special,dx1,dy1,dx2,dy2,false))
5212 5102 dir=ndir2;
5213
5214
4/4
✓ Branch 0 taken 158137 times.
✓ Branch 1 taken 6017 times.
✓ Branch 2 taken 150795 times.
✓ Branch 3 taken 7342 times.
164154 if(dir==ndir && (newrate>=4)) // newrate>=4, otherwise movement is biased toward upper-left
5215 // due to numerous lost fractional components. -L
5216 {
5217 7342 x.doFloor();
5218 7342 y.doFloor();
5219 7342 }
5220 164154 }
5221
5222 551951 return;
5223 }
5224
5225 // can't move straight, must turn
5226 34059 int32_t i=0;
5227
5228 // TODO: speed this up!
5229
2/2
✓ Branch 0 taken 73 times.
✓ Branch 1 taken 64145 times.
64218 for(; i<32; i++) // Try random dir
5230 {
5231 64145 ndir=(zc_oldrand()&7)+8;
5232
5233
2/2
✓ Branch 0 taken 30159 times.
✓ Branch 1 taken 33986 times.
64145 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5234 33986 break;
5235 30159 }
5236
5237
2/2
✓ Branch 0 taken 33986 times.
✓ Branch 1 taken 73 times.
34115 if(i==32)
5238 {
5239
2/2
✓ Branch 0 taken 485 times.
✓ Branch 1 taken 56 times.
541 for(ndir=8; ndir<16; ndir++)
5240 {
5241
2/2
✓ Branch 0 taken 468 times.
✓ Branch 1 taken 17 times.
485 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5242 17 goto ok;
5243 468 }
5244
5245
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5246 56 }
5247
5248 ok:
5249 34059 dir=ndir;
5250 34059 x.doFloor();
5251 34059 y.doFloor();
5252 600279 }
5253
5254 593804 void enemy::newdir_8(int32_t newrate,int32_t newhoming,int32_t special)
5255 {
5256 593804 newdir_8(newrate,newhoming,special,0,-8,15,15);
5257 593804 }
5258
5259 562 void enemy::newdir_8_old(int32_t newrate,int32_t newhoming,int32_t special)
5260 {
5261 562 newdir_8_old(newrate,newhoming,special,0,-8,15,15);
5262 562 }
5263
5264 // makes the enemy slide backwards when hit
5265 // sclk: first byte is clk, second byte is dir
5266 // makes the enemy slide backwards when hit
5267 // sclk: first byte is clk, second byte is dir
5268 16426906 int32_t enemy::slide()
5269 {
5270
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16426906 times.
16426906 if(script_knockback_clk!=0) //scripted knockback
5271 {
5272 sclk = 0;
5273 return 1; //scripted knockback ran
5274 }
5275
5/6
✓ Branch 0 taken 112516 times.
✓ Branch 1 taken 16314390 times.
✓ Branch 2 taken 8816 times.
✓ Branch 3 taken 103700 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 8816 times.
16426906 if(sclk==0 || (hp<=0 && !immortal))
5276 16323206 return 0;
5277
5278
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 103700 times.
103700 if(knockbackflags & FLAG_NOSLIDE)
5279 {
5280 sclk = 0;
5281 if(!OFFGRID_ENEMY)
5282 {
5283 //Fix to grid
5284 do_fix(x, 16, true);
5285 do_fix(y, 16, true);
5286 }
5287 return 0;
5288 }
5289
8/10
✓ Branch 0 taken 10496 times.
✓ Branch 1 taken 93204 times.
✓ Branch 2 taken 1240 times.
✓ Branch 3 taken 9256 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1240 times.
✓ Branch 6 taken 7047 times.
✓ Branch 7 taken 2209 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1240 times.
103700 if((sclk&255)==16 && (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION) || knockbackSpeed!=4 ? !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : 12),0,true) : !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : knockbackSpeed),0,0,0,15,15,true)))
5290 {
5291 2209 sclk=0;
5292 2209 return 0;
5293 }
5294
5295 101491 --sclk;
5296
5297
5/5
✓ Branch 0 taken 2215 times.
✓ Branch 1 taken 11704 times.
✓ Branch 2 taken 13482 times.
✓ Branch 3 taken 35799 times.
✓ Branch 4 taken 38291 times.
101491 switch(sclk>>8)
5298 {
5299 case up:
5300 {
5301
4/4
✓ Branch 0 taken 1090 times.
✓ Branch 1 taken 10614 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 11697 times.
11704 if(y<=(dmisc2==e2tSPLITHIT ? 0 : (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION)?16:0))) //vires
5302 {
5303 7 sclk=0;
5304 7 return 0;
5305 }
5306
4/4
✓ Branch 0 taken 1090 times.
✓ Branch 1 taken 10607 times.
✓ Branch 2 taken 915 times.
✓ Branch 3 taken 175 times.
11697 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5307
5308 11522 break;
5309 }
5310 case down:
5311 {
5312
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 13480 times.
13482 if(y>=(dmisc2==e2tSPLITHIT ? 150 : 160)) //was 160 --changed for vires bug.
5313 {
5314 2 sclk=0;
5315 2 return 0;
5316 }
5317
4/4
✓ Branch 0 taken 1069 times.
✓ Branch 1 taken 12411 times.
✓ Branch 2 taken 923 times.
✓ Branch 3 taken 146 times.
13480 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5318
5319 13334 break;
5320 }
5321 case left:
5322 {
5323
4/4
✓ Branch 0 taken 2354 times.
✓ Branch 1 taken 33445 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 35786 times.
35799 if(x<=(dmisc2==e2tSPLITHIT ? 0 : (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION)?16:0)))
5324 {
5325 13 sclk=0;
5326 13 return 0;
5327 }
5328
4/4
✓ Branch 0 taken 2354 times.
✓ Branch 1 taken 33432 times.
✓ Branch 2 taken 2116 times.
✓ Branch 3 taken 238 times.
35786 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; }
5329
5330 35548 break;
5331 }
5332 case right:
5333 {
5334
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38291 times.
38291 if(x>=(dmisc2==e2tSPLITHIT ? 255 : 240)) //vires
5335 {
5336 sclk=0;
5337 return 0;
5338 }
5339
4/4
✓ Branch 0 taken 3288 times.
✓ Branch 1 taken 35003 times.
✓ Branch 2 taken 3018 times.
✓ Branch 3 taken 270 times.
38291 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5340 38021 break;
5341 }
5342 }
5343
5344 100640 int32_t move = knockbackSpeed;
5345
2/2
✓ Branch 0 taken 95201 times.
✓ Branch 1 taken 100640 times.
195841 while(move>0)
5346 {
5347
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100640 times.
100640 int32_t thismove = zc_min(8, move);
5348 100640 move -= thismove;
5349 100640 hitdir = (sclk>>8);
5350
5/5
✓ Branch 0 taken 2215 times.
✓ Branch 1 taken 11522 times.
✓ Branch 2 taken 13334 times.
✓ Branch 3 taken 35548 times.
✓ Branch 4 taken 38021 times.
100640 switch(sclk>>8)
5351 {
5352 case up:
5353 11522 y-=thismove;
5354 11522 break;
5355
5356 case down:
5357 13334 y+=thismove;
5358 13334 break;
5359
5360 case left:
5361 35548 x-=thismove;
5362 35548 break;
5363
5364 case right:
5365 38021 x+=thismove;
5366 38021 break;
5367 }
5368
2/2
✓ Branch 0 taken 95201 times.
✓ Branch 1 taken 5439 times.
100640 if(!canmove(sclk>>8,(zfix)0,0,true))
5369 {
5370
3/3
✓ Branch 0 taken 2227 times.
✓ Branch 1 taken 3208 times.
✓ Branch 2 taken 4 times.
5439 switch(sclk>>8)
5371 {
5372 case up:
5373 case down:
5374
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2227 times.
2227 if(y < 0)
5375 y = 0;
5376
2/2
✓ Branch 0 taken 378 times.
✓ Branch 1 taken 1849 times.
2227 else if((int32_t(y)&15) > 7)
5377 378 y = TRUNCATE_TILE(int32_t(y)) + 16;
5378 else
5379 1849 y = TRUNCATE_TILE(int32_t(y));
5380
5381 2227 break;
5382
5383 case left:
5384 case right:
5385
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 3167 times.
3208 if(x < 0)
5386 41 x = 0;
5387
2/2
✓ Branch 0 taken 909 times.
✓ Branch 1 taken 2258 times.
3167 else if((int32_t(x)&15) > 7)
5388 909 x = TRUNCATE_TILE(int32_t(x)) + 16;
5389 else
5390 2258 x = TRUNCATE_TILE(int32_t(x));
5391
5392 3208 break;
5393 }
5394
5395 5439 sclk=0;
5396 5439 clk3=0;
5397 5439 break;
5398 }
5399 }
5400
5401
2/2
✓ Branch 0 taken 92423 times.
✓ Branch 1 taken 8217 times.
100640 if((sclk&255)==0)
5402 {
5403 //hitdir = -1;
5404 8217 sclk=0;
5405 8217 }
5406 100640 return 2;
5407 16426906 }
5408
5409 bool enemy::can_slide()
5410 {
5411 if(sclk==0 || (hp<=0 && !immortal))
5412 return false;
5413
5414 if((sclk&255)==16 && (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION) || knockbackSpeed!=4 ? !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : 12),0,true) : !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : knockbackSpeed),0,true)))
5415 {
5416 return false;
5417 }
5418
5419 return true;
5420 }
5421
5422 bool enemy::fslide()
5423 {
5424 if(sclk==0 || (hp<=0 && !immortal))
5425 return false;
5426
5427 if((sclk&255)==16 && !canmove(sclk>>8,(zfix)12,spw_floater,true))
5428 {
5429 sclk=0;
5430 return false;
5431 }
5432
5433 --sclk;
5434
5435 switch(sclk>>8)
5436 {
5437 case up:
5438 if(y<=16)
5439 {
5440 sclk=0;
5441 return false;
5442 }
5443
5444 break;
5445
5446 case down:
5447 if(y>=world_h-16)
5448 {
5449 sclk=0;
5450 return false;
5451 }
5452
5453 break;
5454
5455 case left:
5456 if(x<=16)
5457 {
5458 sclk=0;
5459 return false;
5460 }
5461
5462 break;
5463
5464 case right:
5465 if(x>=world_w-16)
5466 {
5467 sclk=0;
5468 return false;
5469 }
5470
5471 break;
5472 }
5473 hitdir = (sclk>>8);
5474 switch(sclk>>8)
5475 {
5476 case up:
5477 y-=4;
5478 break;
5479
5480 case down:
5481 y+=4;
5482 break;
5483
5484 case left:
5485 x-=4;
5486 break;
5487
5488 case right:
5489 x+=4;
5490 break;
5491 }
5492
5493 if(!canmove(sclk>>8,(zfix)0,spw_floater,true))
5494 {
5495 switch(sclk>>8)
5496 {
5497 case up:
5498 case down:
5499 if((int32_t(y)&15) > 7)
5500 y = TRUNCATE_TILE(int32_t(y)) + 16;
5501 else
5502 y = TRUNCATE_TILE(int32_t(y));
5503
5504 break;
5505
5506 case left:
5507 case right:
5508 if((int32_t(x)&15) > 7)
5509 x = TRUNCATE_TILE(int32_t(x)) + 16;
5510 else
5511 x = TRUNCATE_TILE(int32_t(x));
5512
5513 break;
5514 }
5515
5516 sclk=0;
5517 clk3=0;
5518 }
5519
5520 if((sclk&255)==0)
5521 sclk=0;
5522
5523 return true;
5524 }
5525
5526 bool enemy::knockback(int32_t time, int32_t dir, int32_t speed)
5527 {
5528 if((hp<=0 && !immortal)) return false; //No knocking back dead/mid-knockback enemies
5529 if(!canmove(dir,(zfix)speed,0,0,0,15,15,true)) return false; //from slide(); collision check
5530 bool ret = sprite::knockback(time, dir, speed);
5531 if(ret) sclk = 0; //kill engine knockback if interrupted
5532 //! Perhaps also set hitdir here, if needed for timing? -Z
5533 return ret;
5534 }
5535
5536 39022607 bool enemy::runKnockback()
5537 {
5538
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39022607 times.
39022607 if((script_knockback_clk&0xFF)==0)
5539 {
5540 39022607 script_knockback_clk = 0;
5541 39022607 return false;
5542 }
5543 if(knockbackflags & FLAG_NOSCRIPTKNOCKBACK)
5544 {
5545 return false;
5546 }
5547 int32_t move = script_knockback_speed;
5548 int32_t kb_dir = script_knockback_clk>>8;
5549 --script_knockback_clk;
5550
5551 while(move>0)
5552 {
5553 int32_t thismove = zc_min(get_qr(qr_OLD_SCRIPTED_KNOCKBACK)?8:4, move);
5554 move -= thismove;
5555 hitdir = kb_dir;
5556 switch(kb_dir)
5557 {
5558 case r_up:
5559 case l_up:
5560 case up:
5561 y-=thismove;
5562 break;
5563
5564 case r_down:
5565 case l_down:
5566 case down:
5567 y+=thismove;
5568 break;
5569 }
5570 switch(kb_dir)
5571 {
5572 case l_up:
5573 case l_down:
5574 case left:
5575 x-=thismove;
5576 break;
5577
5578 case r_up:
5579 case r_down:
5580 case right:
5581 x+=thismove;
5582 break;
5583 }
5584 if (get_qr(qr_OLD_SCRIPTED_KNOCKBACK))
5585 {
5586 if(!canmove(kb_dir,(zfix)0,0,true))
5587 {
5588 script_knockback_clk=0;
5589 clk3=0;
5590 //Fix to grid
5591 switch(kb_dir)
5592 {
5593 case up:
5594 case down:
5595 break;
5596 default:
5597 if(x < 0)
5598 x = 0;
5599 else if((int32_t(x)&15) > 7)
5600 x = TRUNCATE_TILE(int32_t(x)) + 16;
5601 else
5602 x = TRUNCATE_TILE(int32_t(x));
5603 break;
5604 }
5605 switch(kb_dir)
5606 {
5607 case left:
5608 case right:
5609 break;
5610 default:
5611 if(y < 0)
5612 y = 0;
5613 else if((int32_t(y)&15) > 7)
5614 y = TRUNCATE_TILE(int32_t(y)) + 16;
5615 else
5616 y = TRUNCATE_TILE(int32_t(y));
5617 break;
5618 }
5619 break;
5620 }
5621 }
5622 else
5623 {
5624 if(!scr_canplace(x,y,0,true))
5625 {
5626 script_knockback_clk=0;
5627 clk3=0;
5628 //Fix to grid
5629 if (OFFGRID_ENEMY)
5630 {
5631 switch(kb_dir)
5632 {
5633 case up:
5634 case down:
5635 break;
5636 default:
5637 if(x < 0)
5638 x = 0;
5639 else if((int32_t(x)&7) > 3)
5640 x = TRUNCATE_HALF_TILE(int32_t(x)) + 8;
5641 else
5642 x = TRUNCATE_HALF_TILE(int32_t(x));
5643 break;
5644 }
5645 switch(kb_dir)
5646 {
5647 case left:
5648 case right:
5649 break;
5650 default:
5651 if(y < 0)
5652 y = 0;
5653 else if((int32_t(y)&7) > 3)
5654 y = TRUNCATE_HALF_TILE(int32_t(y)) + 8;
5655 else
5656 y = TRUNCATE_HALF_TILE(int32_t(y));
5657 break;
5658 }
5659 }
5660 else
5661 {
5662 switch(kb_dir)
5663 {
5664 case up:
5665 case down:
5666 break;
5667 default:
5668 if(x < 0)
5669 x = 0;
5670 else if((int32_t(x)&15) > 7)
5671 x = TRUNCATE_TILE(int32_t(x)) + 16;
5672 else
5673 x = TRUNCATE_TILE(int32_t(x));
5674 break;
5675 }
5676 switch(kb_dir)
5677 {
5678 case left:
5679 case right:
5680 break;
5681 default:
5682 if(y < 0)
5683 y = 0;
5684 else if((int32_t(y)&15) > 7)
5685 y = TRUNCATE_TILE(int32_t(y)) + 16;
5686 else
5687 y = TRUNCATE_TILE(int32_t(y));
5688 break;
5689 }
5690 }
5691 break;
5692 }
5693
5694 }
5695 }
5696 return true;
5697 39022607 }
5698 // changes enemy's direction, checking restrictions
5699 // rate: 0 = no random changes, 16 = always random change
5700 // homing: 0 = none, 256 = always
5701 // grumble 0 = none, 4 = strongest appetite
5702 543806 void enemy::newdir(int32_t newrate,int32_t newhoming,int32_t special)
5703 {
5704 543806 int32_t ndir=-1;
5705
5706
4/4
✓ Branch 0 taken 115116 times.
✓ Branch 1 taken 428690 times.
✓ Branch 2 taken 40416 times.
✓ Branch 3 taken 74700 times.
543806 if(grumble != 0 && (zc_oldrand()&3)<abs(grumble))
5707 {
5708 74700 int32_t i = Lwpns.idFirst(wBait);
5709
1/2
✓ Branch 0 taken 74700 times.
✗ Branch 1 not taken.
74700 if(i >= 0) //idfirst returns -1 if it can't find any
5710 {
5711 weapon *w = (weapon*)Lwpns.spr(i);
5712 if (get_qr(qr_FIND_CLOSEST_BAIT))
5713 {
5714 int32_t currentrange;
5715 if (distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0) currentrange = distance(x, y, w->x, w->y);
5716 else currentrange = -1;
5717 int curid = i;
5718 ++i; //increment beforehand cause we just checked the first bait weapon and all others must be after it. ...otherwise it wouldn't be the first. -Deedee
5719 for(; i<Lwpns.Count(); ++i)
5720 {
5721 weapon *lw = (weapon*)Lwpns.spr(i);
5722 if (lw->id == wBait && distance(x, y, lw->x, lw->y) < currentrange && (distance(x, y, lw->x, lw->y) < lw->misc2 || lw->misc2 == 0))
5723 {
5724 currentrange = distance(x, y, lw->x, lw->y);
5725 curid = i;
5726 }
5727 }
5728 i = curid;
5729 if (currentrange == -1) i = -1;
5730 }
5731 else
5732 {
5733 if (!(distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0)) i = -1;
5734 }
5735 if (i >= 0)
5736 {
5737 int32_t bx = Lwpns.spr(i)->x;
5738 int32_t by = Lwpns.spr(i)->y;
5739
5740 if(abs(int32_t(y)-by)>14)
5741 {
5742 ndir = (by<y) ? up : down;
5743 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & item_flag1)) ndir = oppositeDir[ndir];
5744 if(canmove(ndir,special,false))
5745 {
5746 dir=ndir;
5747 return;
5748 }
5749 }
5750
5751 ndir = (bx<x) ? left : right;
5752 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & item_flag1)) ndir = oppositeDir[ndir];
5753 if(canmove(ndir,special,false))
5754 {
5755 dir=ndir;
5756 return;
5757 }
5758 }
5759 }
5760 74700 }
5761
5762
2/2
✓ Branch 0 taken 366111 times.
✓ Branch 1 taken 177695 times.
543806 if((zc_oldrand()&255)<abs(newhoming))
5763 {
5764 177695 ndir = lined_up(8,false);
5765
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 177695 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
177695 if (newhoming < 0 && ndir >= 0) ndir = oppositeDir[ndir];
5766
4/4
✓ Branch 0 taken 47587 times.
✓ Branch 1 taken 130108 times.
✓ Branch 2 taken 5915 times.
✓ Branch 3 taken 41672 times.
177695 if(ndir>=0 && canmove(ndir,special,false))
5767 {
5768 41672 dir=ndir;
5769 41672 return;
5770 }
5771 136023 }
5772
5773 502134 int32_t i=0;
5774
5775
2/2
✓ Branch 0 taken 3951 times.
✓ Branch 1 taken 1243488 times.
1247439 for(; i<32; i++)
5776 {
5777 1243488 int32_t r=zc_oldrand();
5778
5779
2/2
✓ Branch 0 taken 356725 times.
✓ Branch 1 taken 886763 times.
1243488 if((r&15)<newrate)
5780 356725 ndir=(r>>4)&3;
5781 else
5782 886763 ndir=dir;
5783
5784
2/2
✓ Branch 0 taken 745305 times.
✓ Branch 1 taken 498183 times.
1243488 if(canmove(ndir,special,false))
5785 498183 break;
5786 745305 }
5787
5788
2/2
✓ Branch 0 taken 498183 times.
✓ Branch 1 taken 3951 times.
502896 if(i==32)
5789 {
5790
2/2
✓ Branch 0 taken 9934 times.
✓ Branch 1 taken 762 times.
10696 for(ndir=0; ndir<4; ndir++)
5791 {
5792
2/2
✓ Branch 0 taken 6745 times.
✓ Branch 1 taken 3189 times.
9934 if(canmove(ndir,special,false))
5793 3189 goto ok;
5794 6745 }
5795
5796
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 702 times.
762 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5797 //...Isn't that the point? I'm not sure I understand. Certainly beats phasing through walls... -Dimi
5798 762 }
5799
5800 ok:
5801 502134 dir = ndir;
5802 543806 }
5803
5804 2822 void enemy::newdir()
5805 {
5806 2822 newdir(4,0,spw_none);
5807 2822 }
5808
5809 zfix enemy::distance_left()
5810 {
5811 int32_t a2=x.getInt();
5812 int32_t b2=y.getInt();
5813
5814 switch(dir)
5815 {
5816 case up:
5817 return (zfix)(b2&0xF);
5818
5819 case down:
5820 return (zfix)(16-(b2&0xF));
5821
5822 case left:
5823 return (zfix)(a2&0xF);
5824
5825 case right:
5826 return (zfix)(16-(a2&0xF));
5827 }
5828
5829 return (zfix)0;
5830 }
5831
5832 // keeps walking around
5833 397833 void enemy::constant_walk(int32_t newrate,int32_t newhoming,int32_t special)
5834 {
5835
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 397833 times.
397833 if(slide())
5836 return;
5837
5838
8/12
✓ Branch 0 taken 393987 times.
✓ Branch 1 taken 3846 times.
✓ Branch 2 taken 393987 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 389427 times.
✓ Branch 5 taken 4560 times.
✓ Branch 6 taken 389427 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 389427 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 389427 times.
397833 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock )
5839 8406 return;
5840
5841
2/2
✓ Branch 0 taken 26349 times.
✓ Branch 1 taken 363078 times.
389427 if(clk3<=0)
5842 {
5843 26349 fix_coords(true);
5844 26349 newdir(newrate,newhoming,special);
5845
5846
1/2
✓ Branch 0 taken 26349 times.
✗ Branch 1 not taken.
26349 if(step==0)
5847 clk3=0;
5848 else
5849 26349 clk3=int32_t(16.0/step);
5850 26349 }
5851
2/2
✓ Branch 0 taken 363029 times.
✓ Branch 1 taken 49 times.
363078 else if(scored)
5852 {
5853 49 dir^=1;
5854
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49 times.
49 if (step != 0) clk3=int32_t(16.0/step)-clk3;
5855 else clk3=32767;
5856 49 }
5857
5858
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 389427 times.
389427 if (step != 0) --clk3;
5859 389427 move(step);
5860 397833 }
5861
5862 void enemy::constant_walk()
5863 {
5864 constant_walk(4,0,spw_none);
5865 }
5866
5867 43048 int32_t enemy::pos(int32_t newx,int32_t newy)
5868 {
5869 43048 return (newy<<8)+newx;
5870 }
5871
5872 // for variable step rates
5873 570827 void enemy::variable_walk(int32_t newrate,int32_t newhoming,int32_t special)
5874 {
5875
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 570827 times.
570827 if(slide())
5876 return;
5877
5878
10/14
✓ Branch 0 taken 570827 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 570827 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 562132 times.
✓ Branch 5 taken 8695 times.
✓ Branch 6 taken 552858 times.
✓ Branch 7 taken 9274 times.
✓ Branch 8 taken 496046 times.
✓ Branch 9 taken 56812 times.
✓ Branch 10 taken 496046 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 496046 times.
✗ Branch 13 not taken.
570827 if(clk<0 || dying || stunclk || watch || step == 0 || ceiling || frozenclock )
5879 74781 return;
5880
5881 496046 zfix dx = (zfix)0;
5882 496046 zfix dy = (zfix)0;
5883
5884
5/9
✓ Branch 0 taken 118413 times.
✓ Branch 1 taken 122486 times.
✓ Branch 2 taken 123941 times.
✓ Branch 3 taken 128998 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 2208 times.
496046 switch(dir)
5885 {
5886 case 8:
5887 case up:
5888 118413 dy-=step;
5889 118413 break;
5890
5891 case 12:
5892 case down:
5893 122486 dy+=step;
5894 122486 break;
5895
5896 case 14:
5897 case left:
5898 123941 dx-=step;
5899 123941 break;
5900
5901 case 10:
5902 case right:
5903 128998 dx+=step;
5904 128998 break;
5905
5906 case 15:
5907 case l_up:
5908 dx-=step;
5909 dy-=step;
5910 break;
5911
5912 case 9:
5913 case r_up:
5914 dx+=step;
5915 dy-=step;
5916 break;
5917
5918 case 13:
5919 case l_down:
5920 dx-=step;
5921 dy+=step;
5922 break;
5923
5924 case 11:
5925 case r_down:
5926 dx+=step;
5927 dy+=step;
5928 break;
5929 }
5930
5931
8/8
✓ Branch 0 taken 255737 times.
✓ Branch 1 taken 240309 times.
✓ Branch 2 taken 27253 times.
✓ Branch 3 taken 228484 times.
✓ Branch 4 taken 13974 times.
✓ Branch 5 taken 13279 times.
✓ Branch 6 taken 480251 times.
✓ Branch 7 taken 15795 times.
496046 if(((int32_t(x)&15)==0 && (int32_t(y)&15)==0 && clk3!=pos(x,y)) ||
5932 482072 m_walkflag(int32_t(x+dx),int32_t(y+dy), spw_halfstep, dir))
5933 {
5934 15795 fix_coords();
5935 15795 newdir(newrate,newhoming,special);
5936 15795 clk3=pos(x,y);
5937 15795 }
5938
5939 496046 move(step);
5940 570827 }
5941
5942 // pauses for a while after it makes a complete move (to a new square)
5943 12789274 void enemy::halting_walk(int32_t newrate,int32_t newhoming,int32_t special,int32_t newhrate, int32_t haltcnt)
5944 {
5945
4/4
✓ Branch 0 taken 85091 times.
✓ Branch 1 taken 12704183 times.
✓ Branch 2 taken 71149 times.
✓ Branch 3 taken 13942 times.
12789274 if(sclk && clk2)
5946 {
5947 13942 clk3=0;
5948 13942 }
5949
5950
11/14
✓ Branch 0 taken 12711505 times.
✓ Branch 1 taken 77769 times.
✓ Branch 2 taken 12711505 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12711505 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12242919 times.
✓ Branch 7 taken 468586 times.
✓ Branch 8 taken 12105170 times.
✓ Branch 9 taken 137749 times.
✓ Branch 10 taken 12094281 times.
✓ Branch 11 taken 10889 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 12094281 times.
12789274 if(slide() || clk<0 || dying || stunclk || watch || ceiling || frozenclock)
5951 {
5952 694993 return;
5953 }
5954
5955
2/2
✓ Branch 0 taken 2228493 times.
✓ Branch 1 taken 9865788 times.
12094281 if(clk2>0)
5956 {
5957 2228493 --clk2;
5958 2228493 return;
5959 }
5960
5961
2/2
✓ Branch 0 taken 428146 times.
✓ Branch 1 taken 9437642 times.
9865788 if(clk3<=0)
5962 {
5963 428146 fix_coords(true);
5964 428146 newdir(newrate,newhoming,special);
5965 428146 clk3=int32_t(16.0/step);
5966
2/2
✓ Branch 0 taken 427949 times.
✓ Branch 1 taken 197 times.
428146 if (step == 0) clk3 = 32767; //It used to return this in 2.53 and I'm unsure why; I'm guessing dividing by 0 gave max int? Either way, can't be 0 here or scripts break.
5967
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 428146 times.
428146 if(clk2<0)
5968 {
5969 clk2=0;
5970 }
5971
2/2
✓ Branch 0 taken 57028 times.
✓ Branch 1 taken 371118 times.
428146 else if((zc_oldrand()&15)<newhrate)
5972 {
5973 57028 clk2=haltcnt;
5974 57028 return;
5975 }
5976 371118 }
5977
2/2
✓ Branch 0 taken 9434349 times.
✓ Branch 1 taken 3293 times.
9437642 else if(scored)
5978 {
5979 3293 dir^=1;
5980
5981
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 3288 times.
3293 if (step != 0) clk3=int32_t(16.0/step)-clk3;
5982 5 else clk3=32767;
5983 3293 }
5984
5985
2/2
✓ Branch 0 taken 76939 times.
✓ Branch 1 taken 9731821 times.
9808760 if (step != 0) --clk3;
5986 9808760 move(step);
5987 12789274 }
5988
5989 // 8-directional movement, aligns to 8 pixels
5990 void enemy::constant_walk_8(int32_t newrate,int32_t newhoming,int32_t special)
5991 {
5992 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
5993 return;
5994
5995 if(clk3<=0)
5996 {
5997 newdir_8(newrate,newhoming,special);
5998 clk3=int32_t(8.0/step);
5999 if (step == 0) clk3 = 32767;
6000 }
6001
6002 if (step != 0) --clk3;
6003 move(step);
6004 }
6005 // 8-directional movement, aligns to 8 pixels
6006 242393 void enemy::constant_walk_8_old(int32_t newrate,int32_t newhoming,int32_t special)
6007 {
6008
6/12
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 242393 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 242393 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 242393 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 242393 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 242393 times.
242393 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6009 return;
6010
6011
2/2
✓ Branch 0 taken 226158 times.
✓ Branch 1 taken 16235 times.
242393 if(clk3<=0)
6012 {
6013 16235 newdir_8(newrate,newhoming,special);
6014 16235 clk3=int32_t(8.0/step);
6015
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16235 times.
16235 if (step == 0) clk3 = 32767;
6016 16235 }
6017
6018
1/2
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
242393 if (step != 0) --clk3;
6019 242393 move(step);
6020 242393 }
6021
6022 void enemy::halting_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special,int32_t newhrate, int32_t haltcnt)
6023 {
6024 if(clk<0 || dying || stunclk || watch || frozenclock)
6025 return;
6026
6027 if(!canmove(dir,step,special,false))
6028 clk3=0;
6029
6030 if(clk2>0)
6031 {
6032 --clk2;
6033 return;
6034 }
6035
6036 if(clk3<=0)
6037 {
6038 newdir_8(newrate,newhoming,special);
6039 clk3=newclk;
6040
6041 if(clk2<0)
6042 {
6043 clk2=0;
6044 }
6045 else if((zc_oldrand()&15)<newhrate)
6046 {
6047 newdir_8(newrate,newhoming,special);
6048 clk2=haltcnt;
6049 return;
6050 }
6051 }
6052
6053 --clk3;
6054 move(step);
6055 }
6056
6057 // 8-directional movement, no alignment
6058 4872408 void enemy::variable_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special)
6059 {
6060
9/12
✓ Branch 0 taken 4661743 times.
✓ Branch 1 taken 210665 times.
✓ Branch 2 taken 4661743 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4635122 times.
✓ Branch 5 taken 26621 times.
✓ Branch 6 taken 4624075 times.
✓ Branch 7 taken 11047 times.
✓ Branch 8 taken 4624075 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 4624075 times.
4872408 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6061 248333 return;
6062
6063
2/2
✓ Branch 0 taken 4592191 times.
✓ Branch 1 taken 31884 times.
4624075 if(!canmove(dir,step,special,false))
6064 31884 clk3=0;
6065
6066
2/2
✓ Branch 0 taken 4046506 times.
✓ Branch 1 taken 577569 times.
4624075 if(clk3<=0)
6067 {
6068 577569 newdir_8(newrate,newhoming,special);
6069 577569 clk3=newclk;
6070 577569 }
6071
6072 4624075 --clk3;
6073 4624075 move(step);
6074 4872408 }
6075
6076 // same as above but with variable enemy size
6077 94563 void enemy::variable_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
6078 {
6079
8/12
✓ Branch 0 taken 93367 times.
✓ Branch 1 taken 1196 times.
✓ Branch 2 taken 93367 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 93367 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 93316 times.
✓ Branch 7 taken 51 times.
✓ Branch 8 taken 93316 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 93316 times.
94563 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6080 1247 return;
6081
6082
2/2
✓ Branch 0 taken 91982 times.
✓ Branch 1 taken 1334 times.
93316 if(!canmove(dir,step,special,dx1,dy1,dx2,dy2,false))
6083 1334 clk3=0;
6084
6085
2/2
✓ Branch 0 taken 86841 times.
✓ Branch 1 taken 6475 times.
93316 if(clk3<=0)
6086 {
6087 6475 newdir_8(newrate,newhoming,special,dx1,dy1,dx2,dy2);
6088 6475 clk3=newclk;
6089 6475 }
6090
6091 93316 --clk3;
6092 93316 move(step);
6093 94563 }
6094
6095 // the variable speed floater movement
6096 // ms is max speed
6097 // ss is step speed
6098 // s is step count
6099 // p is pause count
6100 // g is graduality :)
6101 //floater_walk(rate,hrate,dstep/100,(zfix)0,10,dmisc16,dmisc17);
6102 4170490 void enemy::floater_walk(int32_t newrate,int32_t newclk,zfix ms,zfix ss,int32_t s,int32_t p, int32_t g)
6103 {
6104 4170490 ++clk2;
6105 4170490 bool over_pit = overpit();
6106
6107
4/4
✓ Branch 0 taken 1127398 times.
✓ Branch 1 taken 3043092 times.
✓ Branch 2 taken 1127057 times.
✓ Branch 3 taken 341 times.
4170490 if(dmisc1 && over_pit) p = 0;
6108
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 58167 times.
✓ Branch 2 taken 1664287 times.
✓ Branch 3 taken 2309513 times.
✓ Branch 4 taken 138523 times.
4170490 switch(movestatus)
6109 {
6110 //! This needs a case 4 (landing)....if we want to halt, we move to case 4, and
6111 //! if the conditions prevent it, we jump back to case 2.
6112 case 0: // paused
6113
2/2
✓ Branch 0 taken 56695 times.
✓ Branch 1 taken 1472 times.
58167 if(clk2>=p)
6114 {
6115 1472 movestatus=1;
6116 1472 clk2=0;
6117 1472 }
6118
6119 58167 break;
6120
6121 case 1: // speeding up
6122
1/2
✓ Branch 0 taken 1664287 times.
✗ Branch 1 not taken.
1664287 if (s >= 0)
6123 {
6124
2/2
✓ Branch 0 taken 1652642 times.
✓ Branch 1 taken 11645 times.
1664287 if(clk2<g*s)
6125 {
6126
2/2
✓ Branch 0 taken 1546014 times.
✓ Branch 1 taken 106628 times.
1652642 if(!((clk2-1)%g))
6127 106628 step+=ss;
6128 1652642 }
6129 else
6130 {
6131 11645 movestatus=2;
6132 11645 clk2=0;
6133 }
6134 1664287 }
6135 else
6136 {
6137 if(step < ms)
6138 {
6139 if(!((clk2-1)%g))
6140 {
6141 step+=ss;
6142 if (step >= ms) step = ms;
6143 }
6144 }
6145 else
6146 {
6147 step = ms;
6148 movestatus=2;
6149 clk2=0;
6150 }
6151 }
6152
6153 1664287 break;
6154
6155 case 2: // normal
6156 2309513 step=ms;
6157
6158
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2309513 times.
✓ Branch 2 taken 495344 times.
✓ Branch 3 taken 1814169 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1814169 times.
✓ Branch 6 taken 1811852 times.
✓ Branch 7 taken 2317 times.
2309513 if(clk2>(dmisc15>0?dmisc15:48) && !(zc_oldrand()%(dmisc14>0?dmisc14:768)))
6159 {
6160
1/2
✓ Branch 0 taken 2317 times.
✗ Branch 1 not taken.
2317 if (s >= 0) step=ss*s;
6161 else step=ms;
6162 2317 movestatus=3;
6163 2317 clk2=0;
6164 2317 }
6165
6166 2309513 break;
6167
6168 case 3: // slowing down
6169
1/2
✓ Branch 0 taken 138523 times.
✗ Branch 1 not taken.
138523 if (s >= 0)
6170 {
6171
2/2
✓ Branch 0 taken 136812 times.
✓ Branch 1 taken 1711 times.
138523 if(clk2<=g*s)
6172 {
6173 { //don't slow down over pits
6174
6175
2/2
✓ Branch 0 taken 439 times.
✓ Branch 1 taken 136373 times.
136812 if(over_pit)
6176 {
6177
1/2
✓ Branch 0 taken 439 times.
✗ Branch 1 not taken.
439 if(dmisc1)
6178 {
6179 step=ms;
6180 }
6181 439 }
6182 else //can slow down
6183 {
6184
4/4
✓ Branch 0 taken 8399 times.
✓ Branch 1 taken 127974 times.
✓ Branch 2 taken 8031 times.
✓ Branch 3 taken 368 times.
136373 if(!(clk2%g) && !dmisc1)
6185 8031 step-=ss;
6186 }
6187 }
6188
6189
6190 136812 }
6191 else
6192 {
6193 //if((moveflags&move_can_pitfall)) //don't check pits if the enemy ignores them
6194 //this doesn't help keese, as they have a z of 0.
6195 //they always nee to run this check.
6196 {
6197
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1711 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1711 if(over_pit &&!dmisc1)
6198 {
6199 --clk2; //if over a pit, don't land, and revert clock change
6200 }
6201 else //can land safely
6202 {
6203 1711 movestatus=0;
6204
3/4
✓ Branch 0 taken 1128 times.
✓ Branch 1 taken 583 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1128 times.
1711 if(dmisc1&&!over_pit)
6205 1128 step=0;
6206 1711 clk2=0;
6207 }
6208 }
6209
6210 }
6211 138523 }
6212 else
6213 {
6214 if(step > 0)
6215 {
6216 if(over_pit)
6217 {
6218 if(dmisc1)
6219 {
6220 step=ms;
6221 }
6222 }
6223 else //can slow down
6224 {
6225 if(!(clk2%g))
6226 step-=ss;
6227 }
6228 }
6229 else
6230 {
6231 //if((moveflags&move_can_pitfall)) //don't check pits if the enemy ignores them
6232 //this doesn't help keese, as they have a z of 0.
6233 //they always nee to run this check.
6234 if(over_pit)
6235 {
6236 step+=ss; //if over a pit, don't land, and revert clock change
6237 }
6238 else //can land safely
6239 {
6240 movestatus=0;
6241 step=0;
6242 clk2=0;
6243 }
6244 }
6245 }
6246
6247 138523 break;
6248 }
6249
6250
2/2
✓ Branch 0 taken 2318841 times.
✓ Branch 1 taken 1851649 times.
4170490 variable_walk_8(movestatus==2?newrate:0,homing,newclk,spw_floater);
6251 4170490 }
6252
6253 void enemy::floater_walk(int32_t newrate,int32_t newclk,zfix s)
6254 {
6255 floater_walk(newrate,newclk,s,(zfix)0.125,3,80,32);
6256 }
6257
6258 // Checks if enemy is lined up with Hero. If so, returns direction Hero is
6259 // at as compared to enemy. Returns -1 if not lined up. Range is inclusive.
6260 949410 int32_t enemy::lined_up(int32_t range, bool dir8)
6261 {
6262 949410 int32_t lx = Hero.getX();
6263 949410 int32_t ly = Hero.getY();
6264
6265
2/2
✓ Branch 0 taken 40417 times.
✓ Branch 1 taken 908993 times.
949410 if(abs(lx-int32_t(x))<=range)
6266 {
6267
2/2
✓ Branch 0 taken 16864 times.
✓ Branch 1 taken 23553 times.
40417 if(ly<y)
6268 {
6269 16864 return up;
6270 }
6271
6272 23553 return down;
6273 }
6274
6275
2/2
✓ Branch 0 taken 58505 times.
✓ Branch 1 taken 850488 times.
908993 if(abs(ly-int32_t(y))<=range)
6276 {
6277
2/2
✓ Branch 0 taken 31464 times.
✓ Branch 1 taken 27041 times.
58505 if(lx<x)
6278 {
6279 31464 return left;
6280 }
6281
6282 27041 return right;
6283 }
6284
6285
2/2
✓ Branch 0 taken 169486 times.
✓ Branch 1 taken 681002 times.
850488 if(dir8)
6286 {
6287
2/2
✓ Branch 0 taken 256739 times.
✓ Branch 1 taken 424263 times.
681002 if(abs(lx-x)-abs(ly-y)<=range)
6288 //if(abs(lx-x)-abs(ly-y)<=range && abs(ly-y)-abs(lx-x)<=range) //Fix floating enemies not seeking hero. -Tamamo
6289 {
6290
2/2
✓ Branch 0 taken 106856 times.
✓ Branch 1 taken 149883 times.
256739 if(ly<y)
6291 {
6292
2/2
✓ Branch 0 taken 57358 times.
✓ Branch 1 taken 49498 times.
106856 if(lx<x)
6293 {
6294 57358 return l_up;
6295 }
6296 else
6297 {
6298 49498 return r_up;
6299 }
6300 }
6301 else
6302 {
6303
2/2
✓ Branch 0 taken 77422 times.
✓ Branch 1 taken 72461 times.
149883 if(lx<x)
6304 {
6305 72461 return l_down;
6306 }
6307 else
6308 {
6309 77422 return r_down;
6310 }
6311 }
6312 }
6313 424263 }
6314
6315 593749 return -1;
6316 949410 }
6317
6318 // returns true if Hero is within 'range' pixels of the enemy
6319 27887 bool enemy::HeroInRange(int32_t range)
6320 {
6321 27887 int32_t lx = Hero.getX();
6322 27887 int32_t ly = Hero.getY();
6323
2/2
✓ Branch 0 taken 22778 times.
✓ Branch 1 taken 5109 times.
27887 return abs(lx-int32_t(x))<=range && abs(ly-int32_t(y))<=range;
6324 }
6325
6326 // place the enemy in line with Hero (red wizzrobes)
6327 4899 void enemy::place_on_axis(bool floater, bool solid_ok)
6328 {
6329
6/6
✓ Branch 0 taken 587 times.
✓ Branch 1 taken 4312 times.
✓ Branch 2 taken 4355 times.
✓ Branch 3 taken 544 times.
✓ Branch 4 taken 587 times.
✓ Branch 5 taken 3768 times.
4899 int32_t lx=zc_min(zc_max(int32_t(Hero.getX())&0xF0,32),208);
6330
6/6
✓ Branch 0 taken 439 times.
✓ Branch 1 taken 4460 times.
✓ Branch 2 taken 4109 times.
✓ Branch 3 taken 790 times.
✓ Branch 4 taken 439 times.
✓ Branch 5 taken 3670 times.
4899 int32_t ly=zc_min(zc_max(int32_t(Hero.getY())&0xF0,32),128);
6331 4899 int32_t pos2=zc_oldrand()%23;
6332 4899 int32_t tried=0;
6333 4899 bool last_resort,placed=false;
6334
6335
6336 4899 do
6337 {
6338
2/2
✓ Branch 0 taken 4460 times.
✓ Branch 1 taken 3127 times.
7587 if(pos2<14)
6339 {
6340 4460 x=(pos2<<4)+16;
6341 4460 y=ly;
6342 4460 }
6343 else
6344 {
6345 3127 x=lx;
6346 3127 y=((pos2-14)<<4)+16;
6347 }
6348
6349 // Don't commit to a last resort if position is out of bounds.
6350
6/6
✓ Branch 0 taken 7248 times.
✓ Branch 1 taken 339 times.
✓ Branch 2 taken 6936 times.
✓ Branch 3 taken 312 times.
✓ Branch 4 taken 257 times.
✓ Branch 5 taken 6679 times.
7587 last_resort= !(x<32 || y<32 || x>=224 || y>=144);
6351
6352
4/4
✓ Branch 0 taken 3907 times.
✓ Branch 1 taken 3680 times.
✓ Branch 2 taken 4862 times.
✓ Branch 3 taken 1475 times.
7587 if(abs(lx-int32_t(x))>16 || abs(ly-int32_t(y))>16)
6353 {
6354 // Red Wizzrobes should be able to appear on water, but not other
6355 // solid combos; however, they could appear on solid combos in 2.10,
6356 // and some quests depend on that.
6357
4/4
✓ Branch 0 taken 2341 times.
✓ Branch 1 taken 6201 times.
✓ Branch 2 taken 1302 times.
✓ Branch 3 taken 4899 times.
8542 if((solid_ok || !m_walkflag(x,y,floater ? spw_water : spw_door, dir))
6358 8542 && !flyerblocked(x,y,floater ? spw_floater : spw_door))
6359 4899 placed=true;
6360 8542 }
6361
6362
3/6
✓ Branch 0 taken 2688 times.
✓ Branch 1 taken 4725 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2688 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7413 if(!placed && tried>=22 && last_resort)
6363 {
6364 placed=true;
6365 }
6366
6367 7413 ++tried;
6368 7413 pos2=(pos2+3)%23;
6369
2/2
✓ Branch 0 taken 2688 times.
✓ Branch 1 taken 4725 times.
7413 }
6370 7413 while(!placed);
6371
6372
2/2
✓ Branch 0 taken 2917 times.
✓ Branch 1 taken 1808 times.
4725 if(y==ly)
6373 2917 dir=(x<lx)?right:left;
6374 else
6375 1808 dir=(y<ly)?down:up;
6376
6377 4725 clk2=tried;
6378 4725 }
6379
6380 21479608 int32_t enemy::n_frame_n_dir(int32_t frames, int32_t ndir, int32_t f4)
6381 {
6382 21479608 int32_t t = o_tile;
6383 21479608 int32_t b = o_tile;
6384
6385 // Darknuts, but also Wizzrobes and Wallmasters
6386
3/4
✓ Branch 0 taken 8940679 times.
✓ Branch 1 taken 11462151 times.
✓ Branch 2 taken 1076778 times.
✗ Branch 3 not taken.
21479608 switch(type)
6387 {
6388 case eeWALK:
6389
5/6
✓ Branch 0 taken 505407 times.
✓ Branch 1 taken 10956744 times.
✓ Branch 2 taken 367468 times.
✓ Branch 3 taken 137939 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 367468 times.
11462151 if(dmisc9==e9tPOLSVOICE && clk2>=0 && do_animation)
6390 {
6391 367468 tile=s_tile;
6392 367468 t=s_tile;
6393 367468 b=s_tile;
6394 367468 }
6395
6396 11462151 break;
6397
6398 case eeTRAP:
6399
4/6
✓ Branch 0 taken 193566 times.
✓ Branch 1 taken 883212 times.
✓ Branch 2 taken 193566 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 193566 times.
1076778 if(dummy_int[1] && guysbuf[id].flags & guy_trp2 && do_animation) // Just to make sure
6400 {
6401 193566 tile=s_tile;
6402 193566 t=s_tile;
6403 193566 b=s_tile;
6404 193566 }
6405
6406 1076778 break;
6407
6408 case eeSPINTILE:
6409 if(misc>=96 && do_animation)
6410 {
6411 tile=o_tile+frames*ndir;
6412 t=tile;
6413 }
6414
6415 break;
6416 }
6417
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21479608 times.
21479608 if ( do_animation )
6418 {
6419
4/6
✓ Branch 0 taken 197042 times.
✓ Branch 1 taken 21282566 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 267131 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 21015435 times.
21479608 if(ndir!=0) switch(frames)
6420 {
6421 case 2:
6422 267131 tiledir_small(dir,ndir==4);
6423 267131 break;
6424
6425 case 3:
6426 tiledir_three(dir);
6427 break;
6428
6429 case 4:
6430 21015435 tiledir(dir,ndir==4);
6431 21015435 break;
6432 21282566 }
6433
6434
2/2
✓ Branch 0 taken 11462151 times.
✓ Branch 1 taken 10017457 times.
21479608 if(type==eeWALK)
6435
6/6
✓ Branch 0 taken 11400377 times.
✓ Branch 1 taken 61774 times.
✓ Branch 2 taken 8646924 times.
✓ Branch 3 taken 2815227 times.
✓ Branch 4 taken 2799303 times.
✓ Branch 5 taken 15924 times.
11462151 tile=zc_min(tile+f4, t+frames*(zc_max(dir, 0)+1)-1);
6436 else
6437 10017457 tile+=f4;
6438 21479608 }
6439 21479608 return b;
6440 }
6441
6442 void enemy::tiledir_three(int32_t ndir)
6443 {
6444 if ( !do_animation ) return;
6445 flip=0;
6446
6447 switch(ndir)
6448 {
6449 case right:
6450 tile+=3;
6451 [[fallthrough]];
6452
6453 case left:
6454 tile+=3;
6455 [[fallthrough]];
6456
6457 case down:
6458 tile+=3;
6459 [[fallthrough]];
6460
6461 case up:
6462 break;
6463 }
6464 }
6465
6466 267131 void enemy::tiledir_small(int32_t ndir, bool fourdir)
6467 {
6468
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 267131 times.
267131 if ( !do_animation ) return;
6469 267131 flip=0;
6470
6471
8/9
✓ Branch 0 taken 53829 times.
✓ Branch 1 taken 54679 times.
✓ Branch 2 taken 67727 times.
✓ Branch 3 taken 71182 times.
✓ Branch 4 taken 5706 times.
✓ Branch 5 taken 5154 times.
✓ Branch 6 taken 4872 times.
✓ Branch 7 taken 3982 times.
✗ Branch 8 not taken.
267131 switch(ndir)
6472 {
6473 case 8:
6474 case up:
6475 53829 break;
6476
6477 case 12:
6478 case down:
6479 54679 tile+=2;
6480 54679 break;
6481
6482 case 14:
6483 case left:
6484 67727 tile+=4;
6485 67727 break;
6486
6487 case 10:
6488 case right:
6489 71182 tile+=6;
6490 71182 break;
6491
6492 case 9:
6493 case r_up:
6494
1/2
✓ Branch 0 taken 5706 times.
✗ Branch 1 not taken.
5706 if(fourdir)
6495 5706 break;
6496
6497 tile+=10;
6498 break;
6499
6500 case 11:
6501 case r_down:
6502
1/2
✓ Branch 0 taken 5154 times.
✗ Branch 1 not taken.
5154 if(fourdir)
6503 5154 tile+=2;
6504 else
6505 tile+=14;
6506
6507 5154 break;
6508
6509 case 13:
6510 case l_down:
6511
1/2
✓ Branch 0 taken 4872 times.
✗ Branch 1 not taken.
4872 if(fourdir)
6512 4872 tile+=2;
6513 else
6514 tile+=12;
6515
6516 4872 break;
6517
6518 case 15:
6519 case l_up:
6520
1/2
✓ Branch 0 taken 3982 times.
✗ Branch 1 not taken.
3982 if(fourdir)
6521 3982 break;
6522
6523 tile+=8;
6524 break;
6525
6526 default:
6527 //dir=(zc_oldrand()*100)%8;
6528 //tiledir_small(dir);
6529 // flip=zc_oldrand()&3;
6530 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6531 break;
6532 }
6533 267131 }
6534
6535 24500538 void enemy::tiledir(int32_t ndir, bool fourdir)
6536 {
6537
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24500538 times.
24500538 if ( !do_animation ) return;
6538 24500538 flip=0;
6539
6540
9/9
✓ Branch 0 taken 4758764 times.
✓ Branch 1 taken 4413322 times.
✓ Branch 2 taken 5718471 times.
✓ Branch 3 taken 5503275 times.
✓ Branch 4 taken 882607 times.
✓ Branch 5 taken 1091633 times.
✓ Branch 6 taken 1164932 times.
✓ Branch 7 taken 897860 times.
✓ Branch 8 taken 69674 times.
24500538 switch(ndir)
6541 {
6542 case 8:
6543 case up:
6544 4758764 break;
6545
6546 case 12:
6547 case down:
6548 4413322 tile+=4;
6549 4413322 break;
6550
6551 case 14:
6552 case left:
6553 5718471 tile+=8;
6554 5718471 break;
6555
6556 case 10:
6557 case right:
6558 5503275 tile+=12;
6559 5503275 break;
6560
6561 case 9:
6562 case r_up:
6563
2/2
✓ Branch 0 taken 91176 times.
✓ Branch 1 taken 791431 times.
882607 if(fourdir)
6564 91176 break;
6565 else
6566 791431 tile+=24;
6567
6568 791431 break;
6569
6570 case 11:
6571 case r_down:
6572
2/2
✓ Branch 0 taken 103341 times.
✓ Branch 1 taken 988292 times.
1091633 if(fourdir)
6573 103341 tile+=4;
6574 else
6575 988292 tile+=32;
6576
6577 1091633 break;
6578
6579 case 13:
6580 case l_down:
6581
2/2
✓ Branch 0 taken 107670 times.
✓ Branch 1 taken 1057262 times.
1164932 if(fourdir)
6582 107670 tile+=4;
6583 else
6584 1057262 tile+=28;
6585
6586 1164932 break;
6587
6588 case 15:
6589 case l_up:
6590
2/2
✓ Branch 0 taken 87227 times.
✓ Branch 1 taken 810633 times.
897860 if(fourdir)
6591 87227 break;
6592 else
6593 810633 tile+=20;
6594
6595 810633 break;
6596
6597 default:
6598 //dir=(zc_oldrand()*100)%8;
6599 //tiledir(dir);
6600 // flip=zc_oldrand()&3;
6601 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6602 69674 break;
6603 }
6604 24500538 }
6605
6606 3868 void enemy::tiledir_big(int32_t ndir, bool fourdir)
6607 {
6608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if ( !do_animation ) return;
6609 3868 flip=0;
6610
6611
7/9
✓ Branch 0 taken 297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 195 times.
✓ Branch 3 taken 179 times.
✓ Branch 4 taken 306 times.
✓ Branch 5 taken 1235 times.
✓ Branch 6 taken 1324 times.
✓ Branch 7 taken 332 times.
✗ Branch 8 not taken.
3868 switch(ndir)
6612 {
6613 case 8:
6614 case up:
6615 297 break;
6616
6617 case 12:
6618 case down:
6619 tile+=8;
6620 break;
6621
6622 case 14:
6623 case left:
6624 195 tile+=40;
6625 195 break;
6626
6627 case 10:
6628 case right:
6629 179 tile+=48;
6630 179 break;
6631
6632 case 9:
6633 case r_up:
6634
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 306 times.
306 if(fourdir)
6635 break;
6636
6637 306 tile+=88;
6638 306 break;
6639
6640 case 11:
6641 case r_down:
6642
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1235 times.
1235 if(fourdir)
6643 tile+=8;
6644 else
6645 1235 tile+=128;
6646
6647 1235 break;
6648
6649 case 13:
6650 case l_down:
6651
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1324 times.
1324 if(fourdir)
6652 tile+=8;
6653 else
6654 1324 tile+=120;
6655
6656 1324 break;
6657
6658 case 15:
6659 case l_up:
6660
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 332 times.
332 if(fourdir)
6661 break;
6662
6663 332 tile+=80;
6664 332 break;
6665
6666 default:
6667 //dir=(zc_oldrand()*100)%8;
6668 //tiledir_big(dir);
6669 // flip=zc_oldrand()&3;
6670 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6671 break;
6672 }
6673 3868 }
6674
6675 41612879 void enemy::update_enemy_frame()
6676 {
6677
4/4
✓ Branch 0 taken 41609652 times.
✓ Branch 1 taken 3227 times.
✓ Branch 2 taken 1416 times.
✓ Branch 3 taken 41608236 times.
41612879 if(fallclk||drownclk) return;
6678
2/2
✓ Branch 0 taken 41592762 times.
✓ Branch 1 taken 15474 times.
41608236 if (!do_animation)
6679 15474 return;
6680
6681
4/4
✓ Branch 0 taken 2981941 times.
✓ Branch 1 taken 38610821 times.
✓ Branch 2 taken 2976633 times.
✓ Branch 3 taken 5308 times.
41592762 if (get_qr(qr_OLD_TILE_INITIALIZATION) || tile == 0) tile = o_tile; //tile was initialized here before. It needs to be initialized here as well.
6682
6683
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
41592762 if(get_qr(qr_ANONE_NOANIM)
6684
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 41592762 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
41592762 && anim == aNONE && type != eeGUY)
6685 return;
6686
2/2
✓ Branch 0 taken 371376 times.
✓ Branch 1 taken 41221386 times.
41592762 int32_t newfrate = zc_max(frate,4);
6687 41592762 int32_t f4=abs(clk/(newfrate/4)); // casts clk to [0,1,2,3]
6688 41592762 int32_t f2=abs(clk/(newfrate/2)); // casts clk to [0,1]
6689
2/2
✓ Branch 0 taken 31596468 times.
✓ Branch 1 taken 9996294 times.
41592762 int32_t fx = get_qr(qr_NEWENEMYTILES) ? f4 : f2;
6690 41592762 tile = o_tile;
6691 41592762 int32_t basetile = o_tile;
6692 41592762 int32_t tilerows = 1; // How many rows of tiles? The Extend code needs to know.
6693 41592762 bool ignore_extend = false;
6694
35/40
✓ Branch 0 taken 220021 times.
✓ Branch 1 taken 8628 times.
✓ Branch 2 taken 209447 times.
✓ Branch 3 taken 1755010 times.
✓ Branch 4 taken 379205 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 140514 times.
✓ Branch 7 taken 366633 times.
✓ Branch 8 taken 836734 times.
✓ Branch 9 taken 3868 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 5128844 times.
✓ Branch 12 taken 69324 times.
✓ Branch 13 taken 61143 times.
✓ Branch 14 taken 38833 times.
✓ Branch 15 taken 455374 times.
✓ Branch 16 taken 1525813 times.
✓ Branch 17 taken 197042 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 128880 times.
✓ Branch 20 taken 221637 times.
✓ Branch 21 taken 709864 times.
✓ Branch 22 taken 1694695 times.
✓ Branch 23 taken 1160883 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 267131 times.
✓ Branch 26 taken 4365684 times.
✓ Branch 27 taken 7944541 times.
✗ Branch 28 not taken.
✓ Branch 29 taken 582937 times.
✓ Branch 30 taken 1178979 times.
✓ Branch 31 taken 880176 times.
✓ Branch 32 taken 219096 times.
✓ Branch 33 taken 1851190 times.
✓ Branch 34 taken 133344 times.
✓ Branch 35 taken 1433 times.
✓ Branch 36 taken 7487838 times.
✓ Branch 37 taken 882793 times.
✓ Branch 38 taken 276997 times.
✓ Branch 39 taken 208231 times.
41592762 switch(anim)
6695 {
6696
6697 case aDONGO:
6698 {
6699 69324 int32_t fr = stunclk>0 ? 16 : 8;
6700
6701
6/6
✓ Branch 0 taken 67426 times.
✓ Branch 1 taken 1898 times.
✓ Branch 2 taken 6720 times.
✓ Branch 3 taken 60706 times.
✓ Branch 4 taken 2240 times.
✓ Branch 5 taken 4480 times.
69324 if(!dying && clk2>0 && clk2<=64)
6702 {
6703 // bloated
6704
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 960 times.
✓ Branch 2 taken 960 times.
✓ Branch 3 taken 1664 times.
✓ Branch 4 taken 896 times.
4480 switch(dir)
6705 {
6706 case up:
6707 960 tile+=9;
6708 960 flip=0;
6709 960 xofs=0;
6710 960 dummy_int[1]=0; //no additional tiles
6711 960 break;
6712
6713 case down:
6714 960 tile+=7;
6715 960 flip=0;
6716 960 xofs=0;
6717 960 dummy_int[1]=0; //no additional tiles
6718 960 break;
6719
6720 case left:
6721 1664 flip=1;
6722 1664 tile+=4;
6723 1664 xofs=16;
6724 1664 dummy_int[1]=1; //second tile is next tile
6725 1664 break;
6726
6727 case right:
6728 896 flip=0;
6729 896 tile+=5;
6730 896 xofs=16;
6731 896 dummy_int[1]=-1; //second tile is previous tile
6732 896 break;
6733 }
6734 4480 }
6735
4/4
✓ Branch 0 taken 1898 times.
✓ Branch 1 taken 62946 times.
✓ Branch 2 taken 781 times.
✓ Branch 3 taken 1117 times.
64844 else if(!dying || clk2>19)
6736 {
6737 // normal
6738
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 13652 times.
✓ Branch 2 taken 15374 times.
✓ Branch 3 taken 19615 times.
✓ Branch 4 taken 15086 times.
63727 switch(dir)
6739 {
6740 case up:
6741 13652 tile+=8;
6742 13652 flip=(clk&fr)?1:0;
6743 13652 xofs=0;
6744 13652 dummy_int[1]=0; //no additional tiles
6745 13652 break;
6746
6747 case down:
6748 15374 tile+=6;
6749 15374 flip=(clk&fr)?1:0;
6750 15374 xofs=0;
6751 15374 dummy_int[1]=0; //no additional tiles
6752 15374 break;
6753
6754 case left:
6755 19615 flip=1;
6756 19615 tile+=(clk&fr)?2:0;
6757 19615 xofs=16;
6758 19615 dummy_int[1]=1; //second tile is next tile
6759 19615 break;
6760
6761 case right:
6762 15086 flip=0;
6763 15086 tile+=(clk&fr)?3:1;
6764 15086 xofs=16;
6765 15086 dummy_int[1]=-1; //second tile is next tile
6766 15086 break;
6767 }
6768 63727 }
6769 }
6770 69324 break;
6771
6772 case aNEWDONGO:
6773 {
6774 61143 int32_t fr4=0;
6775
6776
6/6
✓ Branch 0 taken 58987 times.
✓ Branch 1 taken 2156 times.
✓ Branch 2 taken 4704 times.
✓ Branch 3 taken 54283 times.
✓ Branch 4 taken 1568 times.
✓ Branch 5 taken 3136 times.
61143 if(!dying && clk2>0 && clk2<=64)
6777 {
6778 // bloated
6779
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3136 times.
3136 if(clk2>=0)
6780 {
6781 3136 fr4=3;
6782 3136 }
6783
6784
2/2
✓ Branch 0 taken 735 times.
✓ Branch 1 taken 2401 times.
3136 if(clk2>=16)
6785 {
6786 2401 fr4=2;
6787 2401 }
6788
6789
2/2
✓ Branch 0 taken 1519 times.
✓ Branch 1 taken 1617 times.
3136 if(clk2>=32)
6790 {
6791 1617 fr4=1;
6792 1617 }
6793
6794
2/2
✓ Branch 0 taken 2303 times.
✓ Branch 1 taken 833 times.
3136 if(clk2>=48)
6795 {
6796 833 fr4=0;
6797 833 }
6798
6799
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 320 times.
✓ Branch 2 taken 640 times.
✓ Branch 3 taken 832 times.
✓ Branch 4 taken 1344 times.
3136 switch(dir)
6800 {
6801 case up:
6802 320 xofs=0;
6803 320 tile+=8+fr4;
6804 320 dummy_int[1]=0; //no additional tiles
6805 320 break;
6806
6807 case down:
6808 640 xofs=0;
6809 640 tile+=12+fr4;
6810 640 dummy_int[1]=0; //no additional tiles
6811 640 break;
6812
6813 case left:
6814 832 tile+=29+(2*fr4);
6815 832 xofs=16;
6816 832 dummy_int[1]=-1; //second tile is previous tile
6817 832 break;
6818
6819 case right:
6820 1344 tile+=49+(2*fr4);
6821 1344 xofs=16;
6822 1344 dummy_int[1]=-1; //second tile is previous tile
6823 1344 break;
6824 }
6825 3136 }
6826
4/4
✓ Branch 0 taken 2156 times.
✓ Branch 1 taken 55851 times.
✓ Branch 2 taken 1136 times.
✓ Branch 3 taken 1020 times.
58007 else if(!dying || clk2>19)
6827 {
6828 // normal
6829
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 10376 times.
✓ Branch 2 taken 10945 times.
✓ Branch 3 taken 17524 times.
✓ Branch 4 taken 18142 times.
56987 switch(dir)
6830 {
6831 case up:
6832 10376 xofs=0;
6833 10376 tile+=((clk&12)>>2);
6834 10376 dummy_int[1]=0; //no additional tiles
6835 10376 break;
6836
6837 case down:
6838 10945 xofs=0;
6839 10945 tile+=4+((clk&12)>>2);
6840 10945 dummy_int[1]=0; //no additional tiles
6841 10945 break;
6842
6843 case left:
6844 17524 tile+=21+((clk&12)>>1);
6845 17524 xofs=16;
6846 17524 dummy_int[1]=-1; //second tile is previous tile
6847 17524 break;
6848
6849 case right:
6850 18142 flip=0;
6851 18142 tile+=41+((clk&12)>>1);
6852 18142 xofs=16;
6853 18142 dummy_int[1]=-1; //second tile is previous tile
6854 18142 break;
6855 }
6856 56987 }
6857 }
6858 61143 break;
6859
6860 case aDONGOBS:
6861 {
6862 38833 int32_t fr4=0;
6863
6864
6/6
✓ Branch 0 taken 37675 times.
✓ Branch 1 taken 1158 times.
✓ Branch 2 taken 4032 times.
✓ Branch 3 taken 33643 times.
✓ Branch 4 taken 1344 times.
✓ Branch 5 taken 2688 times.
38833 if(!dying && clk2>0 && clk2<=64)
6865 {
6866 // bloated
6867
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2688 times.
2688 if(clk2>=0)
6868 {
6869 2688 fr4=3;
6870 2688 }
6871
6872
2/2
✓ Branch 0 taken 630 times.
✓ Branch 1 taken 2058 times.
2688 if(clk2>=16)
6873 {
6874 2058 fr4=2;
6875 2058 }
6876
6877
2/2
✓ Branch 0 taken 1302 times.
✓ Branch 1 taken 1386 times.
2688 if(clk2>=32)
6878 {
6879 1386 fr4=1;
6880 1386 }
6881
6882
2/2
✓ Branch 0 taken 1974 times.
✓ Branch 1 taken 714 times.
2688 if(clk2>=48)
6883 {
6884 714 fr4=0;
6885 714 }
6886
6887
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 256 times.
✓ Branch 2 taken 384 times.
✓ Branch 3 taken 1024 times.
✓ Branch 4 taken 1024 times.
2688 switch(dir)
6888 {
6889 case up:
6890 256 tile+=28+fr4;
6891 256 yofs+=8;
6892 256 dummy_int[1]=-20; //second tile change
6893 256 dummy_int[2]=0; //new xofs change
6894 256 dummy_int[3]=-16; //new xofs change
6895 256 break;
6896
6897 case down:
6898 384 tile+=12+fr4;
6899 384 yofs-=8;
6900 384 dummy_int[1]=20; //second tile change
6901 384 dummy_int[2]=0; //new xofs change
6902 384 dummy_int[3]=16; //new xofs change
6903 384 break;
6904
6905 case left:
6906 1024 tile+=49+(2*fr4);
6907 1024 xofs+=8;
6908 1024 dummy_int[1]=-1; //second tile change
6909 1024 dummy_int[2]=-16; //new xofs change
6910 1024 dummy_int[3]=0; //new xofs change
6911 1024 break;
6912
6913 case right:
6914 1024 tile+=69+(2*fr4);
6915 1024 xofs+=8;
6916 1024 dummy_int[1]=-1; //second tile change
6917 1024 dummy_int[2]=-16; //new xofs change
6918 1024 dummy_int[3]=0; //new xofs change
6919 1024 break;
6920 }
6921 2688 }
6922
4/4
✓ Branch 0 taken 1158 times.
✓ Branch 1 taken 34987 times.
✓ Branch 2 taken 497 times.
✓ Branch 3 taken 661 times.
36145 else if(!dying || clk2>19)
6923 {
6924 // normal
6925
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 7136 times.
✓ Branch 2 taken 6672 times.
✓ Branch 3 taken 11075 times.
✓ Branch 4 taken 10601 times.
35484 switch(dir)
6926 {
6927 case up:
6928 7136 tile+=20+((clk&24)>>3);
6929 7136 yofs+=8;
6930 7136 dummy_int[1]=-20; //second tile change
6931 7136 dummy_int[2]=0; //new xofs change
6932 7136 dummy_int[3]=-16; //new xofs change
6933 7136 break;
6934
6935 case down:
6936 6672 tile+=4+((clk&24)>>3);
6937 6672 yofs-=8;
6938 6672 dummy_int[1]=20; //second tile change
6939 6672 dummy_int[2]=0; //new xofs change
6940 6672 dummy_int[3]=16; //new xofs change
6941 6672 break;
6942
6943 case left:
6944 11075 xofs=-8;
6945 11075 tile+=40+((clk&24)>>2);
6946 11075 dummy_int[1]=1; //second tile change
6947 11075 dummy_int[2]=16; //new xofs change
6948 11075 dummy_int[3]=0; //new xofs change
6949 11075 break;
6950
6951 case right:
6952 10601 tile+=60+((clk&24)>>2);
6953 10601 xofs=-8;
6954 10601 dummy_int[1]=1; //second tile change
6955 10601 dummy_int[2]=16; //new xofs change
6956 10601 dummy_int[3]=0; //new xofs change
6957 10601 break;
6958 }
6959 35484 }
6960 }
6961 38833 break;
6962
6963 case aWIZZ:
6964 {
6965 // if(d->misc1)
6966
2/2
✓ Branch 0 taken 182184 times.
✓ Branch 1 taken 273190 times.
455374 if(dmisc1)
6967 {
6968
2/2
✓ Branch 0 taken 91057 times.
✓ Branch 1 taken 91127 times.
182184 if(clk&8)
6969 {
6970 91127 ++tile;
6971 91127 }
6972 182184 }
6973 else
6974 {
6975
2/2
✓ Branch 0 taken 136701 times.
✓ Branch 1 taken 136489 times.
273190 if(frame&4)
6976 {
6977 136489 ++tile;
6978 136489 }
6979 }
6980
6981
4/4
✓ Branch 0 taken 76094 times.
✓ Branch 1 taken 157108 times.
✓ Branch 2 taken 145581 times.
✓ Branch 3 taken 76591 times.
455374 switch(dir)
6982 {
6983 case 9:
6984 case 15:
6985 case up:
6986 76094 tile+=2;
6987 76094 break;
6988
6989 case down:
6990 76591 break;
6991
6992 case 13:
6993 case left:
6994 157108 flip=1;
6995 157108 break;
6996
6997 default:
6998 145581 flip=0;
6999 145581 break;
7000 }
7001 }
7002 455374 break;
7003
7004 case aNEWWIZZ:
7005 {
7006 1525813 tiledir(dir,true);
7007
7008 // if(d->misc1) //walking wizzrobe
7009
2/2
✓ Branch 0 taken 742424 times.
✓ Branch 1 taken 783389 times.
1525813 if(dmisc1) //walking wizzrobe
7010 {
7011
2/2
✓ Branch 0 taken 373321 times.
✓ Branch 1 taken 369103 times.
742424 if(clk&8)
7012 {
7013 369103 tile+=2;
7014 369103 }
7015
7016
2/2
✓ Branch 0 taken 372085 times.
✓ Branch 1 taken 370339 times.
742424 if(clk&4)
7017 {
7018 370339 tile+=1;
7019 370339 }
7020
7021
2/4
✓ Branch 0 taken 742424 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 742424 times.
742424 if(!(dummy_bool[1]||dummy_bool[2])) //should never be charging or firing for these wizzrobes
7022 {
7023
2/2
✓ Branch 0 taken 663262 times.
✓ Branch 1 taken 79162 times.
742424 if(dummy_int[1]>0)
7024 {
7025 79162 tile+=40;
7026 79162 }
7027 742424 }
7028 742424 }
7029 else
7030 {
7031
4/4
✓ Branch 0 taken 716244 times.
✓ Branch 1 taken 67145 times.
✓ Branch 2 taken 168827 times.
✓ Branch 3 taken 547417 times.
783389 if(dummy_bool[1]||dummy_bool[2])
7032 {
7033 235972 tile+=20;
7034
7035
2/2
✓ Branch 0 taken 67136 times.
✓ Branch 1 taken 168836 times.
235972 if(dummy_bool[2])
7036 {
7037 168836 tile+=20;
7038 168836 }
7039 235972 }
7040
7041 783389 tile+=((frame>>1)&3);
7042 }
7043 }
7044 1525813 break;
7045
7046 case a3FRM:
7047 {
7048
2/2
✓ Branch 0 taken 46675 times.
✓ Branch 1 taken 150367 times.
197042 basetile = n_frame_n_dir(3, 0, (f4==3) ? 1 : f4);
7049 }
7050 197042 break;
7051
7052 case a3FRM4DIR:
7053 {
7054 basetile = n_frame_n_dir(3, 4, (f4==3) ? 1 : f4);
7055 }
7056 break;
7057
7058 case aVIRE:
7059 {
7060
2/2
✓ Branch 0 taken 99588 times.
✓ Branch 1 taken 29292 times.
128880 if(dir==up)
7061 {
7062 29292 tile+=2;
7063 29292 }
7064
7065 128880 tile+=fx;
7066 }
7067 128880 break;
7068
7069 case aROPE:
7070 {
7071 220021 tile+=(1-fx);
7072 220021 flip = dir==left ? 1:0;
7073 }
7074 220021 break;
7075
7076 case aZORA:
7077 {
7078 int32_t dl;
7079
7080
2/2
✓ Branch 0 taken 46739 times.
✓ Branch 1 taken 174898 times.
221637 if(clk<36)
7081 {
7082 46739 dl=clk+5;
7083 46739 goto waves2;
7084 }
7085
7086
2/2
✓ Branch 0 taken 82440 times.
✓ Branch 1 taken 92458 times.
174898 if(clk<36+66)
7087
2/2
✓ Branch 0 taken 50715 times.
✓ Branch 1 taken 31725 times.
82440 tile=(dir==up)?o_tile+1:o_tile;
7088 else
7089 {
7090 92458 dl=clk-36-66;
7091 waves2:
7092 139197 tile=((dl/11)&1)+s_tile;
7093 139197 basetile = s_tile;
7094 }
7095 }
7096 221637 break;
7097
7098 case aNEWZORA:
7099 {
7100 709864 f4=(clk/16)%4;
7101
7102 709864 tiledir(dir,true);
7103 int32_t dl;
7104
7105
4/4
✓ Branch 0 taken 502852 times.
✓ Branch 1 taken 207012 times.
✓ Branch 2 taken 257748 times.
✓ Branch 3 taken 245104 times.
709864 if((clk>35)&&(clk<36+67)) //surfaced
7106 {
7107
4/4
✓ Branch 0 taken 209494 times.
✓ Branch 1 taken 35610 times.
✓ Branch 2 taken 30292 times.
✓ Branch 3 taken 179202 times.
245104 if((clk>=(35+10))&&(clk<(38+56))) //mouth open
7108 {
7109 179202 tile+=80;
7110 179202 } //mouth closed
7111 else
7112 {
7113 65902 tile+=40;
7114 }
7115
7116 245104 tile+=f4;
7117 245104 }
7118 else
7119 {
7120
2/2
✓ Branch 0 taken 207012 times.
✓ Branch 1 taken 257748 times.
464760 if(clk<36)
7121 {
7122 207012 dl=clk+5;
7123 207012 }
7124 else
7125 {
7126 257748 dl=clk-36-66;
7127 }
7128
7129 464760 tile+=((dl/5)&3);
7130 }
7131 }
7132 709864 break;
7133
7134 case a4FRM4EYE:
7135 case a2FRM4EYE:
7136 case a4FRM8EYE:
7137 case a4FRM8EYEB: //big version
7138 case a4FRM4EYEB:
7139 {
7140 836734 tilerows = 2;
7141
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 836734 times.
836734 int fakex = x + 8*(zc_max(1,txsz)-1);
7142
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 836734 times.
836734 int fakey = y + 8*(zc_max(1,tysz)-1);
7143 double _MSVC2022_tmp1, _MSVC2022_tmp2;
7144 836734 double ddir=atan2_MSVC2022_FIX(double(fakey-(Hero.y)),double(Hero.x-fakex));
7145 836734 int32_t lookat=zc_oldrand()&15;
7146
7147
4/4
✓ Branch 0 taken 272091 times.
✓ Branch 1 taken 564643 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 210774 times.
836734 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
7148 {
7149 210774 lookat=l_down;
7150 210774 }
7151
4/4
✓ Branch 0 taken 288167 times.
✓ Branch 1 taken 337793 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 226850 times.
625960 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
7152 {
7153 226850 lookat=down;
7154 226850 }
7155
4/4
✓ Branch 0 taken 170154 times.
✓ Branch 1 taken 228956 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 108837 times.
399110 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
7156 {
7157 108837 lookat=r_down;
7158 108837 }
7159
4/4
✓ Branch 0 taken 131712 times.
✓ Branch 1 taken 158561 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 70395 times.
290273 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
7160 {
7161 70395 lookat=right;
7162 70395 }
7163
4/4
✓ Branch 0 taken 96384 times.
✓ Branch 1 taken 123494 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 35067 times.
219878 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
7164 {
7165 35067 lookat=r_up;
7166 35067 }
7167
4/4
✓ Branch 0 taken 86753 times.
✓ Branch 1 taken 98058 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 25436 times.
184811 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
7168 {
7169 25436 lookat=up;
7170 25436 }
7171
4/4
✓ Branch 0 taken 98120 times.
✓ Branch 1 taken 61255 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 36803 times.
159375 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
7172 {
7173 36803 lookat=l_up;
7174 36803 }
7175 else
7176 {
7177 122572 lookat=left;
7178 }
7179
7180 836734 int32_t dir2 = dir;
7181 836734 dir = lookat;
7182
3/6
✓ Branch 0 taken 836734 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 836734 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 836734 times.
836734 if (anim != a4FRM8EYEB && anim != a4FRM4EYEB) basetile = n_frame_n_dir(anim==a2FRM4EYE ? 2:4, anim==a4FRM8EYE ? 8 : 4, anim==a2FRM4EYE ? (f2&1):f4);
7183 else
7184 {
7185 tiledir_big(dir,(anim == a4FRM4EYEB));
7186 tile+=2*f4;
7187 ignore_extend = true;
7188 }
7189 836734 dir = dir2;
7190 }
7191 836734 break;
7192
7193 case aFLIP:
7194 {
7195 1694695 flip = f2&1;
7196 }
7197 1694695 break;
7198
7199 case a2FRM:
7200 {
7201 1160883 tile += (1-f2);
7202 }
7203 1160883 break;
7204
7205 case a2FRMB:
7206 {
7207 tile+= 2*(1-f2);
7208 ignore_extend = true;
7209 }
7210 break;
7211
7212 case a2FRM4DIR:
7213 {
7214 267131 basetile = n_frame_n_dir(2, 4, f2&1);
7215 }
7216 267131 break;
7217
7218 case a4FRM4DIRF:
7219 {
7220 4365684 basetile = n_frame_n_dir(4,4,f4);
7221
7222
2/2
✓ Branch 0 taken 2886480 times.
✓ Branch 1 taken 1479204 times.
4365684 if(clk2>0) //stopped to fire
7223 {
7224 1479204 tile+=20;
7225
7226
2/2
✓ Branch 0 taken 744443 times.
✓ Branch 1 taken 734761 times.
1479204 if(clk2<17) //firing
7227 {
7228 734761 tile+=20;
7229 734761 }
7230 1479204 }
7231 }
7232 4365684 break;
7233
7234 case a4FRM4DIR:
7235 {
7236 7944541 basetile = n_frame_n_dir(4,4,f4);
7237 }
7238 7944541 break;
7239
7240 case a4FRM8DIRF:
7241 {
7242 tilerows = 2;
7243 basetile = n_frame_n_dir(4,8,f4);
7244
7245 if(clk2>0) //stopped to fire
7246 {
7247 tile+=40;
7248
7249 if(clk2<17) //firing
7250 {
7251 tile+=40;
7252 }
7253 }
7254 }
7255 break;
7256
7257 case a4FRM8DIRB:
7258 case a4FRM8DIRFB:
7259 {
7260 3868 tilerows = 2;
7261 3868 tiledir_big(dir,false);
7262 3868 tile+=2*f4;
7263
3/4
✓ Branch 0 taken 3866 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 3866 times.
✗ Branch 3 not taken.
3868 if(clk2>0 && anim == a4FRM8DIRFB) //stopped to fire
7264 {
7265 tile+=80;
7266
7267 if(clk2<17) //firing
7268 {
7269 tile+=80;
7270 }
7271 }
7272 3868 ignore_extend = true;
7273 }
7274 3868 break;
7275
7276 case a4FRM4DIRB:
7277 case a4FRM4DIRFB:
7278 {
7279 tilerows = 2;
7280 tiledir_big(dir,true);
7281 tile+=2*f4;
7282 if(clk2>0 && anim == a4FRM4DIRFB) //stopped to fire
7283 {
7284 tile+=40;
7285
7286 if(clk2<17) //firing
7287 {
7288 tile+=40;
7289 }
7290 }
7291 ignore_extend = true;
7292 }
7293 break;
7294
7295 case aOCTO:
7296 {
7297
5/5
✓ Branch 0 taken 4152 times.
✓ Branch 1 taken 122459 times.
✓ Branch 2 taken 133448 times.
✓ Branch 3 taken 165651 times.
✓ Branch 4 taken 157227 times.
582937 switch(dir)
7298 {
7299 case up:
7300 122459 flip = 2;
7301 122459 break;
7302
7303 case down:
7304 133448 flip = 0;
7305 133448 break;
7306
7307 case left:
7308 165651 flip = 0;
7309 165651 tile += 2;
7310 165651 break;
7311
7312 case right:
7313 157227 flip = 1;
7314 157227 tile += 2;
7315 157227 break;
7316 }
7317
7318 582937 tile+=f2;
7319 }
7320 582937 break;
7321
7322 case aWALK:
7323 {
7324
5/5
✓ Branch 0 taken 5614 times.
✓ Branch 1 taken 248704 times.
✓ Branch 2 taken 267165 times.
✓ Branch 3 taken 331694 times.
✓ Branch 4 taken 325802 times.
1178979 switch(dir)
7325 {
7326 case up:
7327 248704 tile+=3;
7328 248704 flip = f2;
7329 248704 break;
7330
7331 case down:
7332 267165 tile+=2;
7333 267165 flip = f2;
7334 267165 break;
7335
7336 case left:
7337 331694 flip=1;
7338 331694 tile += f2;
7339 331694 break;
7340
7341 case right:
7342 325802 flip=0;
7343 325802 tile += f2;
7344 325802 break;
7345 }
7346 }
7347 1178979 break;
7348
7349 case aDWALK:
7350 {
7351
3/4
✓ Branch 0 taken 92330 times.
✓ Branch 1 taken 787846 times.
✓ Branch 2 taken 92330 times.
✗ Branch 3 not taken.
880176 if((get_qr(qr_BRKNSHLDTILES)) && (dummy_bool[1]==true))
7352 {
7353 tile=s_tile;
7354 basetile = s_tile;
7355 }
7356
7357
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 177728 times.
✓ Branch 2 taken 185581 times.
✓ Branch 3 taken 260885 times.
✓ Branch 4 taken 255982 times.
880176 switch(dir)
7358 {
7359 case up:
7360 177728 tile+=2;
7361 177728 flip=f2;
7362 177728 break;
7363
7364 case down:
7365 185581 flip=0;
7366 185581 tile+=(1-f2);
7367 185581 break;
7368
7369 case left:
7370 260885 flip=1;
7371 260885 tile+=(3+f2);
7372 260885 break;
7373
7374 case right:
7375 255982 flip=0;
7376 255982 tile+=(3+f2);
7377 255982 break;
7378 }
7379 }
7380 880176 break;
7381
7382 case aTEK:
7383 {
7384
2/2
✓ Branch 0 taken 139976 times.
✓ Branch 1 taken 79120 times.
219096 if(misc==0)
7385 {
7386 79120 tile += f2;
7387 79120 }
7388
2/2
✓ Branch 0 taken 73149 times.
✓ Branch 1 taken 66827 times.
139976 else if(misc!=1)
7389 {
7390 66827 ++tile;
7391 66827 }
7392 }
7393 219096 break;
7394
7395 case aNEWTEK:
7396 {
7397
2/2
✓ Branch 0 taken 486344 times.
✓ Branch 1 taken 1364846 times.
1851190 if(step<0) //up
7398 {
7399
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 241422 times.
✓ Branch 2 taken 244922 times.
486344 switch(clk3)
7400 {
7401 case left:
7402 241422 flip=0;
7403 241422 tile+=20;
7404 241422 break;
7405
7406 case right:
7407 244922 flip=0;
7408 244922 tile+=24;
7409 244922 break;
7410 }
7411 486344 }
7412
2/2
✓ Branch 0 taken 55855 times.
✓ Branch 1 taken 1308991 times.
1364846 else if(step==0)
7413 {
7414
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 41297 times.
✓ Branch 2 taken 14558 times.
55855 switch(clk3)
7415 {
7416 case left:
7417 41297 flip=0;
7418 41297 tile+=8;
7419 41297 break;
7420
7421 case right:
7422 14558 flip=0;
7423 14558 tile+=12;
7424 14558 break;
7425 }
7426 55855 } //down
7427 else
7428 {
7429
3/3
✓ Branch 0 taken 109422 times.
✓ Branch 1 taken 602693 times.
✓ Branch 2 taken 596876 times.
1308991 switch(clk3)
7430 {
7431 case left:
7432 602693 flip=0;
7433 602693 tile+=28;
7434 602693 break;
7435
7436 case right:
7437 596876 flip=0;
7438 596876 tile+=32;
7439 596876 break;
7440 }
7441 }
7442
7443
2/2
✓ Branch 0 taken 1263790 times.
✓ Branch 1 taken 587400 times.
1851190 if(misc==0)
7444 {
7445 587400 tile+=f4;
7446 587400 }
7447
2/2
✓ Branch 0 taken 591200 times.
✓ Branch 1 taken 672590 times.
1263790 else if(misc!=1)
7448 {
7449 672590 tile+=2;
7450 672590 }
7451 }
7452 1851190 break;
7453
7454 case aARMOS:
7455 {
7456
2/2
✓ Branch 0 taken 3227 times.
✓ Branch 1 taken 5401 times.
8628 if(!fading)
7457 {
7458 5401 tile += fx;
7459
7460
2/2
✓ Branch 0 taken 4204 times.
✓ Branch 1 taken 1197 times.
5401 if(dir==up)
7461 1197 tile += 2;
7462 5401 }
7463 }
7464 8628 break;
7465
7466 case aARMOS4:
7467 {
7468
5/5
✓ Branch 0 taken 450 times.
✓ Branch 1 taken 29180 times.
✓ Branch 2 taken 92750 times.
✓ Branch 3 taken 43787 times.
✓ Branch 4 taken 43280 times.
209447 switch(dir)
7469 {
7470 case up:
7471 29180 flip=0;
7472 29180 break;
7473
7474 case down:
7475 92750 flip=0;
7476 92750 tile+=4;
7477 92750 break;
7478
7479 case left:
7480 43787 flip=0;
7481 43787 tile+=8;
7482 43787 break;
7483
7484 case right:
7485 43280 flip=0;
7486 43280 tile+=12;
7487 43280 break;
7488 }
7489
7490
2/2
✓ Branch 0 taken 63277 times.
✓ Branch 1 taken 146170 times.
209447 if(!fading)
7491 {
7492 146170 tile+=f4;
7493 146170 }
7494 }
7495 209447 break;
7496
7497 case aGHINI:
7498 {
7499
4/4
✓ Branch 0 taken 28037 times.
✓ Branch 1 taken 32092 times.
✓ Branch 2 taken 72763 times.
✓ Branch 3 taken 452 times.
133344 switch(dir)
7500 {
7501 case 8:
7502 case 9:
7503 case up:
7504 28037 ++tile;
7505 28037 flip=0;
7506 28037 break;
7507
7508 case 15:
7509 452 ++tile;
7510 452 flip=1;
7511 452 break;
7512
7513 case 10:
7514 case 11:
7515 case right:
7516 32092 flip=1;
7517 32092 break;
7518
7519 default:
7520 72763 flip=0;
7521 72763 break;
7522 }
7523 }
7524 133344 break;
7525
7526 case a2FRMPOS:
7527 {
7528 1755010 tile+=posframe;
7529 }
7530 1755010 break;
7531
7532 case a4FRMPOS4DIR:
7533 {
7534 379205 basetile = n_frame_n_dir(4,4,0);
7535 // tile+=f2;
7536 379205 tile+=posframe;
7537 }
7538 379205 break;
7539
7540 case a4FRMPOS4DIRF:
7541 {
7542 1433 basetile = n_frame_n_dir(4,4,0);
7543
7544
2/2
✓ Branch 0 taken 1236 times.
✓ Branch 1 taken 197 times.
1433 if(clk2>0) //stopped to fire
7545 {
7546 197 tile+=20;
7547
7548
2/2
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 64 times.
197 if(clk2<17) //firing
7549 {
7550 64 tile+=20;
7551 64 }
7552 197 }
7553
7554 // tile+=f2;
7555 1433 tile+=posframe;
7556 }
7557 1433 break;
7558
7559 case a4FRMPOS8DIR:
7560 {
7561 7487838 tilerows = 2;
7562 7487838 int32_t n = tile;
7563 7487838 basetile = n_frame_n_dir(4,8,0);
7564 // tile+=f2;
7565 7487838 tile+=posframe;
7566 }
7567 7487838 break;
7568
7569 case a4FRMPOS8DIRF:
7570 {
7571 tilerows = 2;
7572 basetile = n_frame_n_dir(4,8,0);
7573
7574 if(clk2>0) //stopped to fire
7575 {
7576 tile+=40;
7577
7578 if(clk2<17) //firing
7579 {
7580 tile+=40;
7581 }
7582 }
7583
7584 tile+=posframe;
7585 }
7586 break;
7587
7588 case aNEWLEV:
7589 {
7590 882793 tiledir(dir,true);
7591
7592
4/5
✓ Branch 0 taken 288692 times.
✓ Branch 1 taken 139520 times.
✓ Branch 2 taken 58900 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 395681 times.
882793 switch(misc)
7593 {
7594 case -1:
7595 case 0:
7596 288692 return;
7597
7598 case 1:
7599
7600 // case 5: cs = d->misc2; break;
7601 case 5:
7602 139520 cs = dmisc2;
7603 139520 break;
7604
7605 case 2:
7606 case 4:
7607 58900 tile += 20;
7608 58900 break;
7609
7610 case 3:
7611 395681 tile += 40;
7612 395681 break;
7613 }
7614
7615 594101 tile+=f4;
7616 }
7617 594101 break;
7618
7619 case aLEV:
7620 {
7621 276997 f4 = ((clk/5)&1);
7622
7623
4/5
✓ Branch 0 taken 127945 times.
✓ Branch 1 taken 33336 times.
✓ Branch 2 taken 14658 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 101058 times.
276997 switch(misc)
7624 {
7625 case -1:
7626 case 0:
7627 127945 return;
7628
7629 case 1:
7630
7631 // case 5: tile += (f2) ? 1 : 0; cs = d->misc2; break;
7632 case 5:
7633 33336 tile += (f2) ? 1 : 0;
7634 33336 cs = dmisc2;
7635 33336 break;
7636
7637 case 2:
7638 case 4:
7639 14658 tile += 2;
7640 14658 break;
7641
7642 case 3:
7643 101058 tile += (f4) ? 4 : 3;
7644 101058 break;
7645 }
7646 }
7647 149052 break;
7648
7649 case aWALLM:
7650 {
7651
2/2
✓ Branch 0 taken 750 times.
✓ Branch 1 taken 139764 times.
140514 if(!dummy_bool[1])
7652 {
7653 139764 tile += f2;
7654 139764 }
7655 }
7656 140514 break;
7657
7658 case aNEWWALLM:
7659 {
7660 366633 int32_t tempdir=0;
7661
7662
4/4
✓ Branch 0 taken 38855 times.
✓ Branch 1 taken 43340 times.
✓ Branch 2 taken 8438 times.
✓ Branch 3 taken 276000 times.
366633 switch(misc)
7663 {
7664 case 1:
7665 case 2:
7666 43340 tempdir=clk3;
7667 43340 break;
7668
7669 case 3:
7670 case 4:
7671 case 5:
7672 38855 tempdir=dir;
7673 38855 break;
7674
7675 case 6:
7676 case 7:
7677 8438 tempdir=clk3^1;
7678 8438 break;
7679 }
7680
7681 366633 tiledir(tempdir,true);
7682
7683
2/2
✓ Branch 0 taken 1908 times.
✓ Branch 1 taken 364725 times.
366633 if(!dummy_bool[1])
7684 {
7685 364725 tile+=f4;
7686 364725 }
7687 }
7688 366633 break;
7689
7690 case a4FRMNODIR:
7691 {
7692 208231 tile+=f4;
7693 }
7694 208231 break;
7695
7696 } // switch(d->anim)
7697
7698 // flashing
7699 // if(d->flags & guy_flashing)
7700
2/2
✓ Branch 0 taken 40428576 times.
✓ Branch 1 taken 747549 times.
41176125 if(flags & guy_flashing)
7701 {
7702 747549 cs = (frame&3) + 6;
7703 747549 }
7704
7705
2/2
✓ Branch 0 taken 40749717 times.
✓ Branch 1 taken 426408 times.
41176125 if(flags&guy_transparent)
7706 {
7707 426408 drawstyle=1;
7708 426408 }
7709
7710 41176125 int32_t change = tile-basetile;
7711
7712
3/6
✓ Branch 0 taken 2100068 times.
✓ Branch 1 taken 39076057 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2100068 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
41176125 if(extend > 2 && (!ignore_extend || get_qr(qr_BROKEN_BIG_ENEMY_ANIMATION)))
7713 {
7714
2/2
✓ Branch 0 taken 1817749 times.
✓ Branch 1 taken 282319 times.
2100068 if(basetile/TILES_PER_ROW==(basetile+((txsz*change)/tilerows))/TILES_PER_ROW)
7715 {
7716 1817749 tile=basetile+txsz*change;
7717 1817749 }
7718 else
7719 {
7720 282319 tile=basetile+(txsz*change)+((tysz-1)*TILES_PER_ROW)*(((basetile+txsz*change)/TILES_PER_ROW)-(basetile/TILES_PER_ROW));
7721 }
7722 2100068 }
7723 else
7724 {
7725 39076057 tile=basetile+change;
7726 }
7727 41612879 }
7728
7729 82778 int32_t enemy::wpnsfx(int32_t wpn)
7730 {
7731
3/3
✓ Branch 0 taken 22655 times.
✓ Branch 1 taken 41540 times.
✓ Branch 2 taken 18583 times.
82778 switch (wpn)
7732 {
7733 case wScript1:
7734 case wScript2:
7735 case wScript3:
7736 case wScript4:
7737 case wScript5:
7738 case wScript6:
7739 case wScript7:
7740 case wScript8:
7741 case wScript9:
7742 case wScript10: //sure why not
7743 case ewFireTrail:
7744 case ewFlame:
7745 case ewFlame2Trail:
7746 case ewFlame2:
7747 case ewWind:
7748 case ewMagic:
7749 case ewIce:
7750 22655 return firesfx;
7751
7752 case ewRock:
7753 case ewFireball2:
7754 case ewFireball:
7755
2/2
✓ Branch 0 taken 6082 times.
✓ Branch 1 taken 35458 times.
41540 if (get_qr(qr_MORESOUNDS)) return firesfx;
7756 35458 break;
7757 }
7758
7759 54041 return 0;
7760 82778 }
7761
7762 79108729 int32_t enemy::run_script(int32_t mode)
7763 {
7764 void push_ri();
7765 void pop_ri();
7766
7767
3/4
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 79108473 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 256 times.
79108729 if(switch_hooked && !get_qr(qr_SWITCHOBJ_RUN_SCRIPT)) return RUNSCRIPT_OK;
7768
4/6
✓ Branch 0 taken 230366 times.
✓ Branch 1 taken 78878107 times.
✓ Branch 2 taken 230366 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 230366 times.
79108473 if (script <= 0 || FFCore.getQuestHeaderInfo(vZelda) < 0x255 || FFCore.system_suspend[susptNPCSCRIPTS])
7769 78878107 return RUNSCRIPT_OK;
7770 230366 auto scrty = *get_scrtype();
7771 230366 auto uid = getUID();
7772
1/2
✓ Branch 0 taken 230366 times.
✗ Branch 1 not taken.
230366 if(!FFCore.doscript(scrty,uid))
7773 return RUNSCRIPT_OK;
7774 230366 int32_t ret = RUNSCRIPT_OK;
7775 230366 bool& waitdraw = FFCore.waitdraw(scrty, uid);
7776 230366 push_ri();
7777
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 111621 times.
✓ Branch 2 taken 118745 times.
230366 switch(mode)
7778 {
7779 case MODE_NORMAL:
7780 111621 ret = ZScriptVersion::RunScript(ScriptType::NPC, script, uid);
7781 111621 break;
7782
7783 case MODE_WAITDRAW:
7784
1/2
✓ Branch 0 taken 118745 times.
✗ Branch 1 not taken.
118745 if(waitdraw)
7785 {
7786 ret = ZScriptVersion::RunScript(ScriptType::NPC, script, uid);
7787 waitdraw = false;
7788 }
7789 118745 break;
7790 }
7791 230366 pop_ri();
7792 230366 return ret;
7793 79108729 }
7794 5247 ALLEGRO_COLOR enemy::hitboxColor(byte opacity) const
7795 {
7796 5247 return al_map_rgba(255,0,0,opacity);
7797 }
7798
7799 // good guys, fires, fairy, and other non-enemies
7800 // based on enemy class b/c guys in dungeons act sort of like enemies
7801 // also easier to manage all the guys this way
7802 2198 guy::guy(zfix X,zfix Y,int32_t Id,int32_t Clk,bool mg) : enemy(X,Y,Id,Clk)
7803 2198 {
7804 2198 mainguy=mg;
7805 2198 canfreeze=false;
7806 2198 dir=down;
7807
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2198 times.
✓ Branch 2 taken 2198 times.
✗ Branch 3 not taken.
2198 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
7808 2198 hxofs=2;
7809 2198 hzsz=8;
7810 2198 hit_width=12;
7811 2198 hit_height=17;
7812
7813
10/12
✓ Branch 0 taken 2198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2198 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 765 times.
✓ Branch 5 taken 1433 times.
✓ Branch 6 taken 743 times.
✓ Branch 7 taken 22 times.
✓ Branch 8 taken 276 times.
✓ Branch 9 taken 467 times.
✓ Branch 10 taken 16 times.
✓ Branch 11 taken 260 times.
2198 if(!superman && (!isdungeon(screen_spawned) || id==gFAIRY || id==gFIRE || id==gZELDA))
7814 {
7815 1938 superman = 1;
7816 1938 hxofs=1000;
7817 1938 }
7818 2198 }
7819
7820 945874 bool guy::animate(int32_t index)
7821 {
7822
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 945874 times.
945874 if(switch_hooked) return enemy::animate(index);
7823
6/6
✓ Branch 0 taken 545304 times.
✓ Branch 1 taken 400570 times.
✓ Branch 2 taken 8309 times.
✓ Branch 3 taken 536995 times.
✓ Branch 4 taken 7096 times.
✓ Branch 5 taken 1213 times.
945874 if(mainguy && clk==0 && misc==0)
7824 {
7825 1213 setupscreen();
7826 1213 misc = 1;
7827 1213 }
7828
7829
4/4
✓ Branch 0 taken 545304 times.
✓ Branch 1 taken 400570 times.
✓ Branch 2 taken 544974 times.
✓ Branch 3 taken 330 times.
945874 if(mainguy && fadeclk==0)
7830 330 return true;
7831
7832 945544 hp=256; // good guys never die...
7833
7834
4/4
✓ Branch 0 taken 922 times.
✓ Branch 1 taken 944622 times.
✓ Branch 2 taken 906 times.
✓ Branch 3 taken 16 times.
945544 if(hclk && !clk2)
7835 {
7836 // but if they get hit...
7837 16 ++clk2; // only do this once
7838
7839
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 7 times.
16 if(!get_qr(qr_NOGUYFIRES))
7840 {
7841 7 addenemy(screen_spawned,BSZ?64:72,68,eSHOOTFBALL,0);
7842 7 addenemy(screen_spawned,BSZ?176:168,68,eSHOOTFBALL,0);
7843 7 }
7844 16 }
7845
7846 945544 return enemy::animate(index);
7847 945874 }
7848
7849 949646 void guy::draw(BITMAP *dest)
7850 {
7851 949646 update_enemy_frame();
7852
7853
6/6
✓ Branch 0 taken 548867 times.
✓ Branch 1 taken 400779 times.
✓ Branch 2 taken 22911 times.
✓ Branch 3 taken 525956 times.
✓ Branch 4 taken 11064 times.
✓ Branch 5 taken 11847 times.
949646 if(!mainguy || fadeclk<0 || fadeclk&1)
7854 937799 enemy::draw(dest);
7855 949646 }
7856
7857 760 eFire::eFire(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
7858 760 {
7859 760 clk4=0;
7860
4/8
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 760 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 760 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 760 times.
✗ Branch 7 not taken.
760 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
7861 // Spawn type
7862
2/4
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 760 times.
760 if(flags & guy_fade_flicker)
7863 {
7864 clk=0;
7865 superman = 1;
7866 fading=fade_flicker;
7867 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
7868 dir=down;
7869
7870 if(!canmove(down,(zfix)8,spw_none,false))
7871 clk3=int32_t(13.0/step);
7872 }
7873
3/4
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 676 times.
✓ Branch 3 taken 84 times.
760 else if(flags & guy_fade_instant)
7874 {
7875 84 clk=0;
7876 84 }
7877
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
760 if (SIZEflags != 0) init_size_flags();;
7878 760 }
7879
7880 167472 bool eFire::animate(int32_t index)
7881 {
7882
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 167472 times.
167472 if(switch_hooked) return enemy::animate(index);
7883
2/4
✓ Branch 0 taken 167472 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 167472 times.
167472 if(fallclk||drownclk) return enemy::animate(index);
7884
2/2
✓ Branch 0 taken 165756 times.
✓ Branch 1 taken 1716 times.
167472 if(fading)
7885 {
7886
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1715 times.
1716 if(++clk4 > 60)
7887 {
7888 1 clk4=0;
7889 1 superman=0;
7890 1 fading=0;
7891
7892
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1 if(flags&guy_armos && z==0 && fakez==0)
7893 removearmos(x,y);
7894
7895 1 clk2=0;
7896
7897
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(!canmove(down,(zfix)8,spw_none,false))
7898 {
7899 1 dir=0;
7900 1 y = TRUNCATE_TILE(y.getInt());
7901 1 }
7902
7903 1 return Dead(index);
7904 }
7905
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1715 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1715 else if(flags&guy_armos && z==0 && fakez==0 && clk==0)
7906 removearmos(x,y);
7907 1715 }
7908
7909 167471 return enemy::animate(index);
7910 167472 }
7911
7912 351659 void eFire::draw(BITMAP *dest)
7913 {
7914 351659 update_enemy_frame();
7915 351659 enemy::draw(dest);
7916 351659 }
7917
7918 415 int32_t eFire::takehit(weapon *w, weapon* realweap)
7919 {
7920 415 int32_t wpnId = w->id;
7921 415 int32_t wpnDir = w->dir;
7922
7923
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
415 if(wpnId==wHammer && shield && (flags & guy_bkshield)
7924 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
7925 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
7926 {
7927 shield = false;
7928 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
7929
7930 if(get_qr(qr_BRKNSHLDTILES))
7931 o_tile=s_tile;
7932 }
7933
7934 415 int32_t ret = enemy::takehit(w,realweap);
7935 415 return ret;
7936 }
7937
7938 void eFire::break_shield()
7939 {
7940 if(!shield)
7941 return;
7942
7943 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
7944 shield=false;
7945
7946 if(get_qr(qr_BRKNSHLDTILES))
7947 o_tile=s_tile;
7948 }
7949
7950 void eFire::repair_shield()
7951 {
7952 if (shield)
7953 return;
7954
7955 if (!(flags & (guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right)))
7956 return;
7957
7958 shield = true;
7959
7960 if (get_qr(qr_BRKNSHLDTILES))
7961 {
7962 if get_qr(qr_NEWENEMYTILES) o_tile = d->e_tile;
7963 else o_tile = d->tile;
7964 }
7965 }
7966
7967 7780 eOther::eOther(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
7968 7780 {
7969 7780 clk4=0;
7970
4/8
✓ Branch 0 taken 7780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7780 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7780 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 7780 times.
✗ Branch 7 not taken.
7780 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
7971
7972 // Spawn type
7973
2/4
✓ Branch 0 taken 7780 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7780 times.
7780 if(flags & guy_fade_flicker)
7974 {
7975 clk=0;
7976 superman = 1;
7977 fading=fade_flicker;
7978 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
7979 dir=down;
7980
7981 if(!canmove(down,(zfix)8,spw_none,false))
7982 clk3=int32_t(13.0/step);
7983 }
7984
3/4
✓ Branch 0 taken 7780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6587 times.
✓ Branch 3 taken 1193 times.
7780 else if(flags & guy_fade_instant)
7985 {
7986 1193 clk=0;
7987 1193 }
7988
3/4
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 7745 times.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
7780 if (SIZEflags != 0) init_size_flags();;
7989 7780 }
7990
7991 2069428 bool eOther::animate(int32_t index)
7992 {
7993
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2069428 times.
2069428 if(switch_hooked) return enemy::animate(index);
7994
4/4
✓ Branch 0 taken 2067842 times.
✓ Branch 1 taken 1586 times.
✓ Branch 2 taken 65 times.
✓ Branch 3 taken 2067777 times.
2069428 if(fallclk||drownclk) return enemy::animate(index);
7995
2/2
✓ Branch 0 taken 2059241 times.
✓ Branch 1 taken 8536 times.
2067777 if(fading)
7996 {
7997
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 8507 times.
8536 if(++clk4 > 60)
7998 {
7999 29 clk4=0;
8000 29 superman=0;
8001 29 fading=0;
8002
8003
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
29 if(flags&guy_armos && z==0 && fakez==0)
8004 removearmos(x,y);
8005
8006 29 clk2=0;
8007
8008
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 2 times.
29 if(!canmove(down,(zfix)8,spw_none,false))
8009 {
8010 2 dir=0;
8011 2 y = TRUNCATE_TILE(y.getInt());
8012 2 }
8013
8014 29 return Dead(index);
8015 }
8016
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 8507 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
8507 else if(flags&guy_armos && z==0 && fakez==0 && clk==0)
8017 removearmos(x,y);
8018 8507 }
8019
8020 2067748 return enemy::animate(index);
8021 2069428 }
8022
8023 2202629 void eOther::draw(BITMAP *dest)
8024 {
8025 2202629 update_enemy_frame();
8026 2202629 enemy::draw(dest);
8027 2202629 }
8028
8029 15414 int32_t eOther::takehit(weapon *w, weapon* realweap)
8030 {
8031 15414 int32_t wpnId = w->id;
8032 15414 int32_t wpnDir = w->dir;
8033
8034
4/4
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 15323 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 75 times.
15414 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8035
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
16 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
8036 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
8037 {
8038 shield = false;
8039 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
8040
8041 if(get_qr(qr_BRKNSHLDTILES))
8042 o_tile=s_tile;
8043 }
8044
8045 15414 int32_t ret = enemy::takehit(w,realweap);
8046 15414 return ret;
8047 }
8048
8049 3 void eOther::break_shield()
8050 {
8051
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!shield)
8052 return;
8053
8054 3 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
8055 3 shield=false;
8056
8057
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(get_qr(qr_BRKNSHLDTILES))
8058 3 o_tile=s_tile;
8059 3 }
8060
8061 void eOther::repair_shield()
8062 {
8063 if (shield)
8064 return;
8065
8066 if (!(flags & (guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right)))
8067 return;
8068
8069 shield = true;
8070
8071 if (get_qr(qr_BRKNSHLDTILES))
8072 {
8073 if get_qr(qr_NEWENEMYTILES) o_tile = d->e_tile;
8074 else o_tile = d->tile;
8075 }
8076 }
8077
8078 30 eScript::eScript(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8079 30 {
8080 30 clk4=0;
8081
4/8
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 30 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 30 times.
✗ Branch 7 not taken.
30 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
8082
8083 // Spawn type
8084
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 30 times.
30 if(flags & guy_fade_flicker)
8085 {
8086 clk=0;
8087 superman = 1;
8088 fading=fade_flicker;
8089 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8090 dir=down;
8091
8092 if(!canmove(down,(zfix)8,spw_none,false))
8093 clk3=int32_t(13.0/step);
8094 }
8095
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 else if(flags & guy_fade_instant)
8096 {
8097 clk=0;
8098 }
8099
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 28 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
30 if (SIZEflags != 0) init_size_flags();;
8100 30 }
8101
8102 33693 bool eScript::animate(int32_t index)
8103 {
8104
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33693 times.
33693 if(switch_hooked) return enemy::animate(index);
8105
2/4
✓ Branch 0 taken 33693 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 33693 times.
33693 if(fallclk||drownclk) return enemy::animate(index);
8106
1/2
✓ Branch 0 taken 33693 times.
✗ Branch 1 not taken.
33693 if(fading)
8107 {
8108 if(++clk4 > 60)
8109 {
8110 clk4=0;
8111 superman=0;
8112 fading=0;
8113
8114 if(flags&guy_armos && z==0 && fakez==0)
8115 removearmos(x,y);
8116
8117 clk2=0;
8118
8119 if(!canmove(down,(zfix)8,spw_none,false))
8120 {
8121 dir=0;
8122 y = TRUNCATE_TILE(y.getInt());
8123 }
8124
8125 return Dead(index);
8126 }
8127 else if(flags&guy_armos && z==0 && fakez==0 && clk==0)
8128 removearmos(x,y);
8129 }
8130
8131 33693 return enemy::animate(index);
8132 33693 }
8133
8134 41448 void eScript::draw(BITMAP *dest)
8135 {
8136 41448 update_enemy_frame();
8137 41448 enemy::draw(dest);
8138 41448 }
8139
8140 4997 int32_t eScript::takehit(weapon *w, weapon* realweap)
8141 {
8142 4997 int32_t wpnId = w->id;
8143 4997 int32_t wpnDir = w->dir;
8144
8145
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4997 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4997 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8146 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
8147 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
8148 {
8149 shield = false;
8150 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
8151
8152 if(get_qr(qr_BRKNSHLDTILES))
8153 o_tile=s_tile;
8154 }
8155
8156 4997 int32_t ret = enemy::takehit(w,realweap);
8157 4997 return ret;
8158 }
8159
8160 void eScript::break_shield()
8161 {
8162 if(!shield)
8163 return;
8164
8165 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
8166 shield=false;
8167
8168 if(get_qr(qr_BRKNSHLDTILES))
8169 o_tile=s_tile;
8170 }
8171
8172 void eScript::repair_shield()
8173 {
8174 if (shield)
8175 return;
8176
8177 if (!(flags & (guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right)))
8178 return;
8179
8180 shield = true;
8181
8182 if (get_qr(qr_BRKNSHLDTILES))
8183 {
8184 if get_qr(qr_NEWENEMYTILES) o_tile = d->e_tile;
8185 else o_tile = d->tile;
8186 }
8187 }
8188
8189
8190 eFriendly::eFriendly(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8191 {
8192 clk4=0;
8193 hyofs = -32768; //No hitbox initially.
8194 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
8195
8196 // Spawn type
8197 if(flags & guy_fade_flicker)
8198 {
8199 clk=0;
8200 superman = 1;
8201 fading=fade_flicker;
8202 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8203 dir=down;
8204
8205 if(!canmove(down,(zfix)8,spw_none,false))
8206 clk3=int32_t(13.0/step);
8207 }
8208 else if(flags & guy_fade_instant)
8209 {
8210 clk=0;
8211 }
8212 if (SIZEflags != 0) init_size_flags();;
8213 }
8214
8215 bool eFriendly::animate(int32_t index)
8216 {
8217 if(switch_hooked) return enemy::animate(index);
8218 if(fallclk||drownclk) return enemy::animate(index);
8219 if(fading)
8220 {
8221 if(++clk4 > 60)
8222 {
8223 clk4=0;
8224 superman=0;
8225 fading=0;
8226
8227 if(flags&guy_armos && z==0 && fakez==0)
8228 removearmos(x,y);
8229
8230 clk2=0;
8231
8232 if(!canmove(down,(zfix)8,spw_none,false))
8233 {
8234 dir=0;
8235 y = TRUNCATE_TILE(y.getInt());
8236 }
8237
8238 return Dead(index);
8239 }
8240 else if(flags&guy_armos && z==0 && fakez==0 && clk==0)
8241 removearmos(x,y);
8242 }
8243
8244 return enemy::animate(index);
8245 }
8246
8247 void eFriendly::draw(BITMAP *dest)
8248 {
8249 update_enemy_frame();
8250 enemy::draw(dest);
8251 }
8252
8253 int32_t eFriendly::takehit(weapon *w, weapon* realweap)
8254 {
8255 int32_t wpnId = w->id;
8256 int32_t wpnDir = w->dir;
8257
8258 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8259 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
8260 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
8261 {
8262 shield = false;
8263 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
8264
8265 if(get_qr(qr_BRKNSHLDTILES))
8266 o_tile=s_tile;
8267 }
8268
8269 int32_t ret = enemy::takehit(w,realweap);
8270 return ret;
8271 }
8272
8273 void eFriendly::break_shield()
8274 {
8275 if(!shield)
8276 return;
8277
8278 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
8279 shield=false;
8280
8281 if(get_qr(qr_BRKNSHLDTILES))
8282 o_tile=s_tile;
8283 }
8284
8285 void eFriendly::repair_shield()
8286 {
8287 if (shield)
8288 return;
8289
8290 if (!(flags & (guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right)))
8291 return;
8292
8293 shield = true;
8294
8295 if (get_qr(qr_BRKNSHLDTILES))
8296 {
8297 if get_qr(qr_NEWENEMYTILES) o_tile = d->e_tile;
8298 else o_tile = d->tile;
8299 }
8300 }
8301
8302
8303 790429 void enemy::removearmos(int32_t ax,int32_t ay)
8304 {
8305
2/2
✓ Branch 0 taken 789407 times.
✓ Branch 1 taken 1022 times.
790429 if(did_armos)
8306 789407 return;
8307 1022 did_armos=true;
8308 1022 auto handle = activated_handle;
8309
8310
2/2
✓ Branch 0 taken 322 times.
✓ Branch 1 taken 700 times.
1022 auto layer = handle ? handle->layer() : 0;
8311
3/4
✓ Branch 0 taken 322 times.
✓ Branch 1 taken 700 times.
✓ Branch 2 taken 322 times.
✗ Branch 3 not taken.
1022 if (!handle || handle->is_rpos())
8312 1022 handle = get_rpos_handle_for_world_xy(ax, ay, layer);
8313 1022 mapscr* scr = handle->get_mapscr();
8314
8315 1384 auto [tx, ty] = handle->xy();
8316
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1022 times.
1022 if (handle->is_rpos())
8317 {
8318 2044 tx = TRUNCATE_TILE(ax);
8319 2044 ty = TRUNCATE_TILE(ay);
8320 1022 }
8321
8322 1022 int32_t f = handle->sflag();
8323 1022 int32_t f2 = handle->cflag();
8324
8325
2/2
✓ Branch 0 taken 844 times.
✓ Branch 1 taken 178 times.
1022 if (handle->ctype() != cARMOS)
8326 844 return;
8327
8328
8329
3/4
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 22 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 156 times.
178 if(f == mfARMOS_SECRET || f2 == mfARMOS_SECRET)
8330 {
8331 22 handle->set_data(scr->secretcombo[sSTAIRS]);
8332 22 handle->set_cset(scr->secretcset[sSTAIRS]);
8333 22 handle->set_sflag(scr->secretflag[sSTAIRS]);
8334 22 sfx(scr->secretsfx);
8335 22 }
8336 else
8337 {
8338 156 handle->set_data(scr->undercombo);
8339 156 handle->set_cset(scr->undercset);
8340 156 handle->set_sflag(0);
8341 }
8342
8343
3/4
✓ Branch 0 taken 175 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 175 times.
178 if(f == mfARMOS_ITEM || f2 == mfARMOS_ITEM)
8344 {
8345
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3 if(!getmapflag(scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (scr->flags9&fBELOWRETURN))
8346 {
8347 6 additem(tx,ty,scr->catchall, (ipONETIME2 + ipBIGRANGE) | ((scr->flags3&fHOLDITEM) ? ipHOLDUP : 0) | ((scr->flags8&fITEMSECRET) ? ipSECRETS : 0));
8348 3 sfx(scr->secretsfx);
8349 3 }
8350 3 }
8351
8352 534 putcombo(scrollbuf,tx,ty,handle->data(),handle->cset());
8353 790429 }
8354
8355 461 eGhini::eGhini(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8356 461 {
8357 461 fading=fade_flicker;
8358
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 461 times.
461 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8359 461 dir=12;
8360 461 movestatus=1;
8361
1/2
✓ Branch 0 taken 461 times.
✗ Branch 1 not taken.
461 step=0;
8362 461 clk=0;
8363 461 clk4=0;
8364
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 461 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
461 if (SIZEflags != 0) init_size_flags();;
8365 461 }
8366
8367 117025 bool eGhini::animate(int32_t index)
8368 {
8369
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 117025 times.
117025 if(switch_hooked) return enemy::animate(index);
8370
2/4
✓ Branch 0 taken 117025 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 117025 times.
117025 if(fallclk||drownclk) return enemy::animate(index);
8371
2/2
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 116975 times.
117025 if(dying)
8372 50 return Dead(index);
8373
8374
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116975 times.
116975 if(dmisc1)
8375 {
8376
2/2
✓ Branch 0 taken 89752 times.
✓ Branch 1 taken 27223 times.
116975 if(misc)
8377 {
8378
2/2
✓ Branch 0 taken 34899 times.
✓ Branch 1 taken 54853 times.
89752 if(clk4>160)
8379 54853 misc=2;
8380
8381
2/2
✓ Branch 0 taken 34899 times.
✓ Branch 1 taken 54853 times.
89752 floater_walk((misc==1)?0:rate,hrate,zslongToFix(dstep*100),zslongToFix(dstep*10),10,dmisc16,dmisc17); //120,10);
8382 89752 removearmos(x,y);
8383 89752 }
8384
2/2
✓ Branch 0 taken 26798 times.
✓ Branch 1 taken 425 times.
27223 else if(clk4>=60)
8385 {
8386 425 misc=1;
8387 425 clk3=32;
8388 425 fading=0;
8389
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 285 times.
425 if (activated_handle)
8390 {
8391 140 activation_counters[activated_handle->layer()][activated_handle->id()] = 0;
8392 140 removearmos(x, y);
8393 140 }
8394 else
8395 {
8396 285 rpos_t rpos = COMBOPOS_REGION_B(x, y);
8397
1/2
✓ Branch 0 taken 285 times.
✗ Branch 1 not taken.
285 if (rpos != rpos_t::None)
8398 {
8399 285 activation_counters[0][int(rpos)] = 0;
8400 285 removearmos(x,y);
8401 285 }
8402 }
8403 425 }
8404 116975 }
8405
8406 116975 clk4++;
8407
8408 116975 return enemy::animate(index);
8409 117025 }
8410
8411 238808 void eGhini::draw(BITMAP *dest)
8412 {
8413 238808 update_enemy_frame();
8414 238808 enemy::draw(dest);
8415 238808 }
8416
8417 2 void eGhini::kickbucket()
8418 {
8419 2 hp=-1000; // don't call death_sfx()
8420 2 }
8421
8422
2/4
✓ Branch 0 taken 5303 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5303 times.
✗ Branch 3 not taken.
10606 eTektite::eTektite(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8423 5303 {
8424
1/2
✓ Branch 0 taken 5303 times.
✗ Branch 1 not taken.
5303 old_y=y;
8425 5303 dir=down;
8426 5303 misc=1;
8427 5303 clk=-15;
8428
8429
2/2
✓ Branch 0 taken 2649 times.
✓ Branch 1 taken 2654 times.
5303 if(!BSZ)
8430
1/2
✓ Branch 0 taken 2649 times.
✗ Branch 1 not taken.
2649 clk*=zc_oldrand()%3+1;
8431
8432 // avoid divide by 0 errors
8433
1/2
✓ Branch 0 taken 5303 times.
✗ Branch 1 not taken.
5303 if(dmisc1 == 0)
8434 dmisc1 = 24;
8435
8436
1/2
✓ Branch 0 taken 5303 times.
✗ Branch 1 not taken.
5303 if(dmisc2 == 0)
8437 dmisc2 = 3;
8438
8439 //nets+760;
8440
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5303 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5303 if (SIZEflags != 0) init_size_flags();;
8441 5303 }
8442
8443 1450693 bool eTektite::animate(int32_t index)
8444 {
8445
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1450693 times.
1450693 if(switch_hooked) return enemy::animate(index);
8446
4/4
✓ Branch 0 taken 1439215 times.
✓ Branch 1 taken 11478 times.
✓ Branch 2 taken 11478 times.
✓ Branch 3 taken 1437953 times.
1450693 if(fallclk||drownclk) return enemy::animate(index);
8447
2/2
✓ Branch 0 taken 26967 times.
✓ Branch 1 taken 1410986 times.
1437953 if(dying)
8448 26967 return Dead(index);
8449
8450
2/2
✓ Branch 0 taken 1373549 times.
✓ Branch 1 taken 37437 times.
1410986 if(clk==0)
8451 {
8452 37437 removearmos(x,y);
8453 37437 }
8454
8455
2/2
✓ Branch 0 taken 1058532 times.
✓ Branch 1 taken 352454 times.
1410986 if(get_qr(qr_ENEMIESZAXIS))
8456 {
8457 352454 y=floor_y;
8458 352454 }
8459
8460
9/10
✓ Branch 0 taken 1294828 times.
✓ Branch 1 taken 116158 times.
✓ Branch 2 taken 1281264 times.
✓ Branch 3 taken 13564 times.
✓ Branch 4 taken 1281264 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11176 times.
✓ Branch 7 taken 1270088 times.
✓ Branch 8 taken 10820 times.
✓ Branch 9 taken 21996 times.
1410986 if(clk>=0 && !stunclk && !frozenclock && (!watch || misc==0))
8461 {
8462
4/4
✓ Branch 0 taken 20378 times.
✓ Branch 1 taken 424353 times.
✓ Branch 2 taken 348142 times.
✓ Branch 3 taken 499211 times.
1292084 switch(misc)
8463 {
8464 case 0: // normal
8465
2/2
✓ Branch 0 taken 413019 times.
✓ Branch 1 taken 11334 times.
424353 if (!zc::math::SafeMod(zc_oldrand(), dmisc1))
8466 {
8467 11334 misc=1;
8468 11334 clk2=32;
8469 11334 }
8470
8471 424353 break;
8472
8473 case 1: // waiting to pounce
8474
2/2
✓ Branch 0 taken 327278 times.
✓ Branch 1 taken 20864 times.
348142 if(--clk2<=0)
8475 {
8476 20864 int32_t r=zc_oldrand();
8477 20864 misc=2;
8478 20864 step=0-(zslongToFix(dstep*100)); // initial speed
8479 20864 clk3=(r&1)+2; // left or right
8480 20864 clk2start=clk2=(r&31)+10; // flight time
8481
8482
2/2
✓ Branch 0 taken 18419 times.
✓ Branch 1 taken 2445 times.
20864 if(y<32) clk2+=2; // make them come down from top of screen
8483
8484
2/2
✓ Branch 0 taken 15914 times.
✓ Branch 1 taken 4950 times.
20864 if(y>world_h-64) clk2-=2; // make them go back up
8485
8486 20864 cstart=c = 9-((r&31)>>3); // time before gravity kicks in
8487 20864 }
8488
8489 348142 break;
8490
8491 case 2: // in flight
8492 499211 move(step);
8493
8494
2/2
✓ Branch 0 taken 236916 times.
✓ Branch 1 taken 262295 times.
499211 if(step>0) //going down
8495 {
8496
2/2
✓ Branch 0 taken 632 times.
✓ Branch 1 taken 236284 times.
236916 if(COMBOTYPE(x+8,y+16)==cNOJUMPZONE)
8497 {
8498 632 step=0-step;
8499 632 }
8500
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 236284 times.
236284 else if(COMBOTYPE(x+8,y+16)==cNOENEMY)
8501 {
8502 step=0-step;
8503 }
8504
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 236284 times.
236284 else if(ispitfall(x+8,y+16))
8505 {
8506 step=0-step;
8507 }
8508
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 236237 times.
236284 else if(MAPFLAG(x+8,y+16)==mfNOENEMY)
8509 {
8510 47 step=0-step;
8511 47 }
8512
2/2
✓ Branch 0 taken 236226 times.
✓ Branch 1 taken 11 times.
236237 else if(MAPCOMBOFLAG(x+8,y+16)==mfNOENEMY)
8513 {
8514 11 step=0-step;
8515 11 }
8516 236916 }
8517
2/2
✓ Branch 0 taken 15350 times.
✓ Branch 1 taken 246945 times.
262295 else if(step<0)
8518 {
8519
2/2
✓ Branch 0 taken 438 times.
✓ Branch 1 taken 246507 times.
246945 if(COMBOTYPE(x+8,y)==cNOJUMPZONE)
8520 {
8521 438 step=0-step;
8522 438 }
8523
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 246507 times.
246507 else if(COMBOTYPE(x+8,y)==cNOENEMY)
8524 {
8525 step=0-step;
8526 }
8527
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 246507 times.
246507 else if(ispitfall(x+8,y))
8528 {
8529 step=0-step;
8530 }
8531
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 246486 times.
246507 else if(MAPFLAG(x+8,y)==mfNOENEMY)
8532 {
8533 21 step=0-step;
8534 21 }
8535
2/2
✓ Branch 0 taken 246467 times.
✓ Branch 1 taken 19 times.
246486 else if(MAPCOMBOFLAG(x+8,y)==mfNOENEMY)
8536 {
8537 19 step=0-step;
8538 19 }
8539 246945 }
8540
8541
2/2
✓ Branch 0 taken 247071 times.
✓ Branch 1 taken 252140 times.
499211 if(clk3==left)
8542 {
8543
2/2
✓ Branch 0 taken 275 times.
✓ Branch 1 taken 246796 times.
247071 if(COMBOTYPE(x,y+8)==cNOJUMPZONE)
8544 {
8545 275 clk3^=1;
8546 275 }
8547
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 246790 times.
246796 else if(COMBOTYPE(x,y+8)==cNOENEMY)
8548 {
8549 6 clk3^=1;
8550 6 }
8551
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 246790 times.
246790 else if(ispitfall(x,y+8))
8552 {
8553 clk3^=1;
8554 }
8555
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 246760 times.
246790 else if(MAPFLAG(x,y+8)==mfNOENEMY)
8556 {
8557 30 clk3^=1;
8558 30 }
8559
2/2
✓ Branch 0 taken 246748 times.
✓ Branch 1 taken 12 times.
246760 else if(MAPCOMBOFLAG(x,y+8)==mfNOENEMY)
8560 {
8561 12 clk3^=1;
8562 12 }
8563 247071 }
8564 else
8565 {
8566
2/2
✓ Branch 0 taken 276 times.
✓ Branch 1 taken 251864 times.
252140 if(COMBOTYPE(x+16,y+8)==cNOJUMPZONE)
8567 {
8568 276 clk3^=1;
8569 276 }
8570
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 251852 times.
251864 else if(COMBOTYPE(x+16,y+8)==cNOENEMY)
8571 {
8572 12 clk3^=1;
8573 12 }
8574
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 251852 times.
251852 else if(ispitfall(x+16,y+8))
8575 {
8576 clk3^=1;
8577 }
8578
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 251847 times.
251852 else if(MAPFLAG(x+16,y+8)==mfNOENEMY)
8579 {
8580 5 clk3^=1;
8581 5 }
8582
2/2
✓ Branch 0 taken 251835 times.
✓ Branch 1 taken 12 times.
251847 else if(MAPCOMBOFLAG(x+16,y+8)==mfNOENEMY)
8583 {
8584 12 clk3^=1;
8585 12 }
8586 }
8587
8588 499211 --c;
8589
8590
4/4
✓ Branch 0 taken 153199 times.
✓ Branch 1 taken 346012 times.
✓ Branch 2 taken 324230 times.
✓ Branch 3 taken 174981 times.
499211 if(c<0 && step<zslongToFix(dstep*100))
8591 {
8592 174981 step+=zslongToFix(dmisc3*100);
8593 174981 }
8594
8595 499211 int32_t nb=get_qr(qr_NOBORDER) ? 16 : 0;
8596
8597
2/2
✓ Branch 0 taken 498483 times.
✓ Branch 1 taken 728 times.
499211 if(x<=16-nb) clk3=right;
8598
8599
2/2
✓ Branch 0 taken 498214 times.
✓ Branch 1 taken 997 times.
499211 if(x>=world_w-32+nb) clk3=left;
8600
8601 499211 x += (clk3==left) ? -1 : 1;
8602
8603
4/4
✓ Branch 0 taken 29298 times.
✓ Branch 1 taken 469913 times.
✓ Branch 2 taken 10189 times.
✓ Branch 3 taken 459724 times.
499211 if((--clk2<=0 && y>=16-nb) || y>=world_h-32+nb)
8604 {
8605
4/4
✓ Branch 0 taken 1625 times.
✓ Branch 1 taken 17484 times.
✓ Branch 2 taken 1436 times.
✓ Branch 3 taken 189 times.
39487 if(y>=world_h-32+nb && get_qr(qr_ENEMIESZAXIS))
8606 {
8607 189 step=0-step;
8608 189 y--;
8609 189 }
8610
2/2
✓ Branch 0 taken 5861 times.
✓ Branch 1 taken 13059 times.
18920 else if (zc::math::SafeMod(zc_oldrand(), dmisc2)) //land and wait
8611 {
8612 13059 clk=misc=0;
8613 13059 } //land and jump again
8614 else
8615 {
8616 5861 misc=1;
8617 5861 clk2=0;
8618 }
8619 19109 }
8620
8621 478833 break;
8622 } // switch
8623 1271706 }
8624
8625
4/4
✓ Branch 0 taken 352454 times.
✓ Branch 1 taken 1059794 times.
✓ Branch 2 taken 236998 times.
✓ Branch 3 taken 115456 times.
1412248 if(get_qr(qr_ENEMIESZAXIS) && misc==2)
8626 {
8627
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115456 times.
115456 if (moveflags & move_use_fake_z)
8628 {
8629 int32_t tempy = floor_y;
8630 fakez=zc_max(0,zc_min(clk2start-clk2,clk2));
8631 floor_y = y;
8632 y=tempy-fakez;
8633 old_y = y;
8634 }
8635 else
8636 {
8637 115456 int32_t tempy = floor_y;
8638
6/6
✓ Branch 0 taken 58103 times.
✓ Branch 1 taken 57353 times.
✓ Branch 2 taken 109249 times.
✓ Branch 3 taken 6207 times.
✓ Branch 4 taken 53394 times.
✓ Branch 5 taken 55855 times.
115456 z=zc_max(0,zc_min(clk2start-clk2,clk2));
8639 115456 floor_y = y;
8640 115456 y=tempy-z;
8641 115456 old_y = y;
8642 }
8643 115456 }
8644
8645
4/4
✓ Branch 0 taken 13564 times.
✓ Branch 1 taken 1398684 times.
✓ Branch 2 taken 2927 times.
✓ Branch 3 taken 10637 times.
1412248 if(stunclk && (clk&31)==1)
8646 10637 clk=0;
8647
8648 1412248 return enemy::animate(index);
8649 1439215 }
8650
8651 1004450 bool eTektite::can_drawshadow() const
8652 {
8653
5/6
✓ Branch 0 taken 633102 times.
✓ Branch 1 taken 371348 times.
✓ Branch 2 taken 633102 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 26121 times.
✓ Branch 5 taken 606981 times.
1004450 if(z<1 && fakez<1 && get_qr(qr_ENEMIESZAXIS))
8654 26121 return false;
8655
8656 978329 return enemy::can_drawshadow();
8657 1004450 }
8658 821032 void eTektite::drawshadow(BITMAP *dest,bool translucent)
8659 {
8660
2/2
✓ Branch 0 taken 637614 times.
✓ Branch 1 taken 183418 times.
821032 if(!can_drawshadow())
8661 637614 return;
8662
8663 183418 int32_t tempy=yofs;
8664 183418 int32_t fdiv = frate/4;
8665
1/2
✓ Branch 0 taken 183418 times.
✗ Branch 1 not taken.
183418 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
8666
1/2
✓ Branch 0 taken 183418 times.
✗ Branch 1 not taken.
183418 int32_t f2=get_qr(qr_NEWENEMYTILES)?
8667 183418 efrate:((clk>=(frate>>1))?1:0);
8668 183418 flip = 0;
8669 183418 shadowtile = wpnsbuf[spr_shadow].tile;
8670
8671
1/2
✓ Branch 0 taken 183418 times.
✗ Branch 1 not taken.
183418 if(get_qr(qr_NEWENEMYTILES))
8672 {
8673
2/2
✓ Branch 0 taken 114485 times.
✓ Branch 1 taken 68933 times.
183418 if(misc==0)
8674 {
8675 68933 shadowtile+=f2;
8676 68933 }
8677
2/2
✓ Branch 0 taken 50403 times.
✓ Branch 1 taken 64082 times.
114485 else if(misc!=1)
8678 64082 shadowtile+=2;
8679 183418 }
8680 else
8681 {
8682 if(misc==0)
8683 {
8684 shadowtile += f2 ? 1 : 0;
8685 }
8686 else if(misc!=1)
8687 {
8688 ++shadowtile;
8689 }
8690 }
8691
8692 183418 yofs+=8;
8693
8694
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 183418 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
183418 if(!get_qr(qr_ENEMIESZAXIS) && misc==2)
8695 {
8696 yofs+=zc_max(0,zc_min(clk2start-clk2,clk2));
8697 }
8698 183418 enemy::drawshadow(dest,translucent);
8699 183418 yofs=tempy;
8700 821032 }
8701
8702 2084918 void eTektite::draw(BITMAP *dest)
8703 {
8704 2084918 update_enemy_frame();
8705 2084918 enemy::draw(dest);
8706 2084918 }
8707
8708 736 eItemFairy::eItemFairy(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8709 736 {
8710
2/4
✓ Branch 0 taken 736 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 736 times.
✗ Branch 3 not taken.
736 step=zslongToFix(guysbuf[id&0xFFF].step*100);
8711 736 superman=1;
8712 736 dir=8;
8713 736 hxofs=1000;
8714 736 mainguy=false;
8715 736 count_enemy=false;
8716
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 736 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
736 if (SIZEflags != 0) init_size_flags();;
8717 736 }
8718
8719 280632 bool eItemFairy::animate(int32_t index)
8720 {
8721
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 280632 times.
280632 if(switch_hooked) return enemy::animate(index);
8722
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 280632 times.
280632 if(dying)
8723 return Dead(index);
8724
8725 //if(clk>32)
8726 280632 misc=1;
8727 280632 bool w=watch;
8728 280632 watch=false;
8729 280632 variable_walk_8(misc?3:0,0,8,spw_floater);
8730 280632 watch=w;
8731
8732
2/2
✓ Branch 0 taken 1521 times.
✓ Branch 1 taken 279111 times.
280632 if(clk==0)
8733 {
8734 1521 removearmos(x,y);
8735 1521 }
8736
8737 280632 return enemy::animate(index);
8738 280632 }
8739
8740 563612 void eItemFairy::draw(BITMAP *dest)
8741 {
8742 //these are here to bypass compiler warnings about unused arguments
8743 563612 dest=dest;
8744 563612 }
8745
8746 1833 ePeahat::ePeahat(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8747 1833 {
8748 //floater_walk(int32_t rate,int32_t newclk,zfix ms,zfix ss,int32_t s,int32_t p, int32_t g)
8749
10/20
✗ Branch 0 not taken.
✓ Branch 1 taken 1833 times.
✓ Branch 2 taken 1833 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1833 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1833 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1833 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1833 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1833 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1833 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 1833 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 1833 times.
✗ Branch 19 not taken.
1833 floater_walk(misc?rate:0, hrate, zslongToFix(dstep*100),zslongToFix(dstep*10), 10, dmisc16,dmisc17); // 80, 16);
8750 1833 dir=8;
8751 1833 movestatus=1;
8752 1833 clk=0;
8753
1/2
✓ Branch 0 taken 1833 times.
✗ Branch 1 not taken.
1833 step=0;
8754 //nets+720;
8755
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1833 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1833 if (SIZEflags != 0) init_size_flags();;
8756 1833 }
8757
8758 522341 bool ePeahat::animate(int32_t index)
8759 {
8760
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 522341 times.
522341 if(switch_hooked) return enemy::animate(index);
8761
2/4
✓ Branch 0 taken 522341 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 522341 times.
522341 if(fallclk||drownclk) return enemy::animate(index);
8762
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 522263 times.
522341 if(slide())
8763 {
8764 78 update_current_screen();
8765 78 return false;
8766 }
8767
8768
2/2
✓ Branch 0 taken 1030 times.
✓ Branch 1 taken 521233 times.
522263 if(dying)
8769 1030 return Dead(index);
8770
8771
2/2
✓ Branch 0 taken 3095 times.
✓ Branch 1 taken 518138 times.
521233 if(clk==0)
8772 {
8773 3095 removearmos(x,y);
8774 3095 }
8775
8776
4/4
✓ Branch 0 taken 518115 times.
✓ Branch 1 taken 3118 times.
✓ Branch 2 taken 254234 times.
✓ Branch 3 taken 263881 times.
521233 if(stunclk==0 && clk>96)
8777 263881 misc=1;
8778
8779
2/2
✓ Branch 0 taken 2402 times.
✓ Branch 1 taken 518831 times.
521233 if(!watch)
8780
2/2
✓ Branch 0 taken 172185 times.
✓ Branch 1 taken 346646 times.
518831 floater_walk(misc?rate:0, hrate, zslongToFix(dstep*100),zslongToFix(dstep*10), 10, 80, 16);
8781
8782
3/4
✓ Branch 0 taken 101744 times.
✓ Branch 1 taken 419489 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 101744 times.
521233 if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
8783 {
8784
1/2
✓ Branch 0 taken 101744 times.
✗ Branch 1 not taken.
101744 if (moveflags & move_use_fake_z) fakez=int32_t(step*1.1/((zslongToFix(dstep*10))*1.1));
8785 101744 else z=int32_t(step*1.1/((zslongToFix(dstep*10))*1.1));
8786 101744 }
8787
8788
4/4
✓ Branch 0 taken 2402 times.
✓ Branch 1 taken 518831 times.
✓ Branch 2 taken 768 times.
✓ Branch 3 taken 1634 times.
521233 if(watch && get_qr(qr_PEAHATCLOCKVULN))
8789 1634 superman=0;
8790 else
8791
2/2
✓ Branch 0 taken 9811 times.
✓ Branch 1 taken 509788 times.
519599 superman=(movestatus && !get_qr(qr_ENEMIESZAXIS)) ? 1 : 0;
8792 //stunclk=0; //Not sure what was going on here, or what was intended. Why was this set to 0? -Z
8793
2/2
✓ Branch 0 taken 266663 times.
✓ Branch 1 taken 254570 times.
521233 if ( FFCore.getQuestHeaderInfo(vZelda) >= 0x250 )
8794 {
8795
2/2
✓ Branch 0 taken 263548 times.
✓ Branch 1 taken 3115 times.
266663 if ( stunclk ) --stunclk;
8796 266663 }
8797 254570 else stunclk = 0; //Was probably this way in 2.10 quests. if not, then we never need to clear it. -Z
8798 //Pretty sure this was always an error. -Z ( 14FEB2019 )
8799
8800
8801
2/2
✓ Branch 0 taken 520993 times.
✓ Branch 1 taken 240 times.
521233 if(x<16) dir=right; //this is ugly, but so is moving or creating these guys with scripts.
8802
8803 521233 return enemy::animate(index);
8804 522341 }
8805
8806 336394 void ePeahat::drawshadow(BITMAP *dest, bool translucent)
8807 {
8808 336394 flip = 0;
8809
2/2
✓ Branch 0 taken 252623 times.
✓ Branch 1 taken 83771 times.
336394 if(!can_drawshadow())
8810 252623 return;
8811 83771 int32_t tempy=yofs;
8812 83771 shadowtile = wpnsbuf[spr_shadow].tile+posframe;
8813
8814
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 83771 times.
83771 if(!get_qr(qr_ENEMIESZAXIS))
8815 {
8816 yofs+=8;
8817 yofs+=int32_t(step/zslongToFix(dstep*10));
8818 }
8819 83771 enemy::drawshadow(dest,translucent);
8820 83771 yofs=tempy;
8821 336394 }
8822
8823 1149824 void ePeahat::draw(BITMAP *dest)
8824 {
8825 1149824 update_enemy_frame();
8826 1149824 enemy::draw(dest);
8827 1149824 }
8828
8829 4136 int32_t ePeahat::takehit(weapon *w, weapon* realweap)
8830 {
8831 4136 int32_t wpnId = w->id;
8832 4136 int32_t enemyHitWeapon = w->parentitem;
8833
8834
3/6
✓ Branch 0 taken 4136 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4136 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4136 times.
4136 if(dying || clk<0 || hclk>0)
8835 return 0;
8836
8837
4/4
✓ Branch 0 taken 3381 times.
✓ Branch 1 taken 755 times.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 206 times.
4380 if(superman && !(wpnId==wSBomb) // vulnerable to super bombs
8838 // fire boomerang, for nailing peahats
8839
4/6
✓ Branch 0 taken 3381 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3137 times.
✓ Branch 3 taken 244 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 244 times.
3381 && !(wpnId==wBrang && (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))>0))
8840 3343 return 0;
8841
8842 // Time for a kludge...
8843 793 int32_t s = superman;
8844 793 superman = 0;
8845 793 int32_t ret = enemy::takehit(w,realweap);
8846 793 superman = s;
8847
8848 // Anyway...
8849
2/2
✓ Branch 0 taken 601 times.
✓ Branch 1 taken 192 times.
793 if(stunclk == 160)
8850 {
8851 192 clk2=0;
8852 192 movestatus=0;
8853 192 misc=0;
8854 192 clk=0;
8855 192 step=0;
8856 192 }
8857
8858 793 return ret;
8859 4136 }
8860
8861 // auomatically kill off enemy (for rooms with ringleaders)
8862 void ePeahat::kickbucket()
8863 {
8864 hp=-1000; // don't call death_sfx()
8865 }
8866
8867 4434 eLeever::eLeever(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8868 4434 {
8869 // if(d->misc1==0) { misc=-1; clk-=16; } //Line of Sight leevers
8870
2/2
✓ Branch 0 taken 2235 times.
✓ Branch 1 taken 2199 times.
4434 if(dmisc1==0)
8871 {
8872 2199 misc=-1; //Line of Sight leevers
8873 2199 clk-=16;
8874 2199 }
8875 4434 clk3 = 0;
8876 //nets+1460;
8877 4434 temprule=(get_qr(qr_NEWENEMYTILES)) != 0;
8878 4434 submerged = false;
8879
1/4
✓ Branch 0 taken 4434 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4434 if (SIZEflags != 0) init_size_flags();;
8880 4434 }
8881
8882 2260 bool eLeever::isSubmerged() const
8883 {
8884 2260 return misc <= 0;
8885 }
8886
8887 1147511 bool eLeever::animate(int32_t index)
8888 {
8889
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1147511 times.
1147511 if(switch_hooked) return enemy::animate(index);
8890
3/4
✓ Branch 0 taken 1146801 times.
✓ Branch 1 taken 710 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1146801 times.
1147511 if(fallclk||drownclk)
8891 {
8892 710 return enemy::animate(index);
8893 }
8894
2/2
✓ Branch 0 taken 33572 times.
✓ Branch 1 taken 1113229 times.
1146801 if(dying)
8895 33572 return Dead(index);
8896
8897
2/2
✓ Branch 0 taken 1061638 times.
✓ Branch 1 taken 51591 times.
1113229 if(clk==0)
8898 {
8899 51591 removearmos(x,y);
8900 51591 }
8901
8902
4/4
✓ Branch 0 taken 925465 times.
✓ Branch 1 taken 187764 times.
✓ Branch 2 taken 7201 times.
✓ Branch 3 taken 918264 times.
1113229 if(clk>=0 && !slide())
8903 {
8904
2/2
✓ Branch 0 taken 347437 times.
✓ Branch 1 taken 570827 times.
918264 switch(dmisc1)
8905 {
8906 case 0: //line of sight
8907 case 2:
8908
7/8
✗ Branch 0 not taken.
✓ Branch 1 taken 126285 times.
✓ Branch 2 taken 50473 times.
✓ Branch 3 taken 36580 times.
✓ Branch 4 taken 16242 times.
✓ Branch 5 taken 106113 times.
✓ Branch 6 taken 4536 times.
✓ Branch 7 taken 7208 times.
347437 switch(misc) //is this leever active
8909 {
8910 case -1: //submerged
8911 {
8912
4/6
✓ Branch 0 taken 8208 times.
✓ Branch 1 taken 118077 times.
✓ Branch 2 taken 8208 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 8208 times.
126285 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 0;
8913
4/4
✓ Branch 0 taken 10299 times.
✓ Branch 1 taken 115986 times.
✓ Branch 2 taken 10261 times.
✓ Branch 3 taken 38 times.
126285 if((dmisc1==2)&&(zc_oldrand()&255))
8914 {
8915 10261 break;
8916 }
8917
8918 116024 int32_t active=0;
8919
8920
2/2
✓ Branch 0 taken 793931 times.
✓ Branch 1 taken 116024 times.
909955 for(int32_t i=0; i<guys.Count(); i++)
8921 {
8922
4/4
✓ Branch 0 taken 634947 times.
✓ Branch 1 taken 158984 times.
✓ Branch 2 taken 405682 times.
✓ Branch 3 taken 229265 times.
793931 if(guys.spr(i)->id==id && (((enemy*)guys.spr(i))->misc>=0))
8923 {
8924 229265 ++active;
8925 229265 }
8926 793931 }
8927
8928
2/2
✓ Branch 0 taken 114100 times.
✓ Branch 1 taken 1924 times.
116024 if(active<((dmisc1==2)?1:2))
8929 {
8930 1924 misc=0; //activate this one
8931 1924 clk3=1; //This needs to be set so that it knows that it's being emerged of its own will and not because it got stunned.
8932 1924 }
8933 }
8934 116024 break;
8935
8936 case 0:
8937 {
8938
8939
4/6
✓ Branch 0 taken 13284 times.
✓ Branch 1 taken 37189 times.
✓ Branch 2 taken 13284 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 13284 times.
50473 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk))
8940 {
8941 misc=1;
8942 clk2=0;
8943 }
8944
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 50415 times.
50473 else if (clk3<=0)
8945 {
8946 58 misc = -1;
8947 58 break;
8948 }
8949 50415 int32_t s=0;
8950
8951
2/2
✓ Branch 0 taken 279841 times.
✓ Branch 1 taken 50415 times.
330256 for(int32_t i=0; i<guys.Count(); i++)
8952 {
8953
4/4
✓ Branch 0 taken 167298 times.
✓ Branch 1 taken 112543 times.
✓ Branch 2 taken 159136 times.
✓ Branch 3 taken 8162 times.
279841 if(guys.spr(i)->id==id && ((enemy*)guys.spr(i))->misc==1)
8954 {
8955 8162 ++s;
8956 8162 }
8957 279841 }
8958
8959
2/2
✓ Branch 0 taken 8162 times.
✓ Branch 1 taken 42253 times.
50415 if(s>0)
8960 {
8961 8162 break;
8962 }
8963
8964 42253 int32_t d2=zc_oldrand()&1;
8965
8966
2/2
✓ Branch 0 taken 14692 times.
✓ Branch 1 taken 27561 times.
42253 if(HeroDir()>=left)
8967 {
8968 27561 d2+=2;
8969 27561 }
8970
8971
4/4
✓ Branch 0 taken 40761 times.
✓ Branch 1 taken 1492 times.
✓ Branch 2 taken 685 times.
✓ Branch 3 taken 40076 times.
42253 if(canplace(d2) || canplace(d2^1))
8972 {
8973 2177 misc=1;
8974 2177 clk2=0;
8975 2177 clk=0;
8976 2177 }
8977 }
8978 42253 break;
8979
8980 case 1:
8981
8982
7/8
✓ Branch 0 taken 34448 times.
✓ Branch 1 taken 2132 times.
✓ Branch 2 taken 4647 times.
✓ Branch 3 taken 29801 times.
✓ Branch 4 taken 4647 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 4646 times.
36580 if(++clk2>16||(!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk) && clk2>8)) misc=2;
8983
8984 36580 break;
8985
8986 case 2:
8987
8988
7/8
✓ Branch 0 taken 14272 times.
✓ Branch 1 taken 1970 times.
✓ Branch 2 taken 1910 times.
✓ Branch 3 taken 12362 times.
✓ Branch 4 taken 1910 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 1909 times.
16242 if(++clk2>24||(!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk) && clk2>12)) misc=3;
8989
8990 16242 break;
8991
8992 // case 3: if(stunclk) break; if(scored) dir^=1; if(!canmove(dir,false)) misc=4; else move((zfix)(d->step/100.0)); break;
8993 case 3:
8994
8995
5/6
✓ Branch 0 taken 102524 times.
✓ Branch 1 taken 3589 times.
✓ Branch 2 taken 102524 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2727 times.
✓ Branch 5 taken 99797 times.
106113 if(stunclk || frozenclock || watch) break;
8996
8997
2/2
✓ Branch 0 taken 143 times.
✓ Branch 1 taken 99654 times.
99797 if(scored) dir^=1;
8998
8999
2/2
✓ Branch 0 taken 524 times.
✓ Branch 1 taken 99273 times.
99797 if(!canmove(dir,false)) misc=4;
9000 99273 else move(zslongToFix(dstep*100));
9001
9002 99797 break;
9003
9004 case 4:
9005
4/6
✓ Branch 0 taken 781 times.
✓ Branch 1 taken 3755 times.
✓ Branch 2 taken 781 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 781 times.
4536 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 2;
9006
2/2
✓ Branch 0 taken 4049 times.
✓ Branch 1 taken 487 times.
4536 if(--clk2<=16)
9007 {
9008 487 misc=5;
9009 487 clk=8;
9010 487 }
9011
9012 4536 break;
9013
9014 case 5:
9015
5/6
✓ Branch 0 taken 1311 times.
✓ Branch 1 taken 5897 times.
✓ Branch 2 taken 1311 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 1310 times.
7208 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 1;
9016
2/2
✓ Branch 0 taken 6780 times.
✓ Branch 1 taken 428 times.
7208 if(--clk2<=0) misc=((dmisc1==2)?-1:0);
9017
9018 7208 break;
9019 } // switch(misc)
9020
9021 347437 break;
9022
9023 default: //random
9024 // step=d->misc3/100.0;
9025
9026 570827 step=zslongToFix(dmisc3*100);
9027
5/6
✓ Branch 0 taken 97013 times.
✓ Branch 1 taken 473814 times.
✓ Branch 2 taken 97013 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 70 times.
✓ Branch 5 taken 96943 times.
570827 if (get_qr(qr_LEEVERS_DONT_OBEY_STUN) || (!watch && !stunclk)) ++clk2;
9028
3/6
✓ Branch 0 taken 70 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 70 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 70 times.
✗ Branch 5 not taken.
70 else if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk))
9029 {
9030
1/2
✓ Branch 0 taken 70 times.
✗ Branch 1 not taken.
70 if (clk2 < 48) clk2+=2;
9031
1/2
✓ Branch 0 taken 70 times.
✗ Branch 1 not taken.
70 if (clk2 >= 300) clk2-=2;
9032 70 }
9033
9034
2/2
✓ Branch 0 taken 75127 times.
✓ Branch 1 taken 495700 times.
570827 if(clk2<32) misc=1;
9035
2/2
✓ Branch 0 taken 37104 times.
✓ Branch 1 taken 458596 times.
495700 else if(clk2<48) misc=2;
9036
2/2
✓ Branch 0 taken 348113 times.
✓ Branch 1 taken 110483 times.
458596 else if(clk2<300)
9037 {
9038 /*if(misc==2 && (int32_t)(dmisc3*0.48)%8)
9039 {
9040 fix_coords();
9041 }*/
9042 348113 misc=3;
9043 348113 step = zslongToFix(dstep*100);
9044 348113 }
9045
2/2
✓ Branch 0 taken 10512 times.
✓ Branch 1 taken 99971 times.
110483 else if(clk2<316) misc=2;
9046
2/2
✓ Branch 0 taken 51567 times.
✓ Branch 1 taken 48404 times.
99971 else if(clk2<412) misc=1;
9047
2/2
✓ Branch 0 taken 48074 times.
✓ Branch 1 taken 330 times.
48404 else if(clk2<540)
9048 {
9049 48074 misc=0;
9050 48074 step=0;
9051 48074 }
9052 330 else clk2=0;
9053
9054
2/2
✓ Branch 0 taken 568557 times.
✓ Branch 1 taken 2270 times.
570827 if(clk2==48) clk=0;
9055
9056 // variable_walk(d->rate, d->homing, 0);
9057 570827 variable_walk(rate, homing, 0);
9058 570827 } // switch(dmisc1)
9059 918264 }
9060
9061 1113229 hxofs=(misc>=2)?0:1000;
9062 1113229 return enemy::animate(index);
9063 1147511 }
9064
9065 83014 bool eLeever::canplace(int32_t d2)
9066 {
9067 83014 int32_t nx=HeroX();
9068 83014 int32_t ny=HeroY();
9069
9070
2/2
✓ Branch 0 taken 28840 times.
✓ Branch 1 taken 54174 times.
83014 if(d2<left) ny=TRUNCATE_TILE(ny);
9071 54174 else nx=TRUNCATE_TILE(nx);
9072
9073
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 14347 times.
✓ Branch 2 taken 14493 times.
✓ Branch 3 taken 27073 times.
✓ Branch 4 taken 27101 times.
83014 switch(d2)
9074 {
9075 case up:
9076
2/2
✓ Branch 0 taken 14317 times.
✓ Branch 1 taken 30 times.
14347 ny-=((dmisc1==0||dmisc1==2)?32:48);
9077 14347 break;
9078
9079 case down:
9080
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 14459 times.
14493 ny+=((dmisc1==0||dmisc1==2)?32:48);
9081
9082
4/4
✓ Branch 0 taken 10212 times.
✓ Branch 1 taken 4281 times.
✓ Branch 2 taken 10201 times.
✓ Branch 3 taken 11 times.
14493 if(ny-HeroY()<32) ny+=((dmisc1==0||dmisc1==2)?16:0);
9083
9084 14493 break;
9085
9086 case left:
9087
2/2
✓ Branch 0 taken 26420 times.
✓ Branch 1 taken 653 times.
27073 nx-=((dmisc1==0||dmisc1==2)?32:48);
9088 27073 break;
9089
9090 case right:
9091
2/2
✓ Branch 0 taken 646 times.
✓ Branch 1 taken 26455 times.
27101 nx+=((dmisc1==0||dmisc1==2)?32:48);
9092
9093
4/4
✓ Branch 0 taken 19994 times.
✓ Branch 1 taken 7107 times.
✓ Branch 2 taken 19392 times.
✓ Branch 3 taken 602 times.
27101 if(nx-HeroX()<32) nx+=((dmisc1==0||dmisc1==2)?16:0);
9094
9095 27101 break;
9096 }
9097
9098
4/4
✓ Branch 0 taken 21099 times.
✓ Branch 1 taken 61915 times.
✓ Branch 2 taken 9435 times.
✓ Branch 3 taken 11664 times.
83014 if(m_walkflag(nx,ny,spw_halfstep, dir)||m_walkflag(nx,ny-8,spw_halfstep, dir)) /*none*/
9099 71350 return false;
9100
9101
2/2
✓ Branch 0 taken 891 times.
✓ Branch 1 taken 10773 times.
11664 if(d2>=left)
9102
4/4
✓ Branch 0 taken 5079 times.
✓ Branch 1 taken 5694 times.
✓ Branch 2 taken 9487 times.
✓ Branch 3 taken 1286 times.
10773 if(m_walkflag(HeroX(),HeroY(),spw_halfstep, dir)||m_walkflag(HeroX(),HeroY()-8,spw_halfstep, dir)) /*none*/
9103 9487 return false;
9104
9105 2177 x=nx;
9106 2177 y=ny;
9107 2177 dir=d2^1;
9108 2177 return true;
9109 83014 }
9110
9111 1160500 void eLeever::draw(BITMAP *dest)
9112 {
9113 // cs=d->cset;
9114 1160500 cs=dcset;
9115 1160500 update_enemy_frame();
9116
3/4
✓ Branch 0 taken 1159790 times.
✓ Branch 1 taken 710 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1159790 times.
1160500 if(!fallclk&&!drownclk)
9117 {
9118
2/2
✓ Branch 0 taken 743153 times.
✓ Branch 1 taken 416637 times.
1159790 switch(misc)
9119 {
9120 case -1:
9121 case 0:
9122 416637 return;
9123 }
9124 743153 }
9125
9126 743863 enemy::draw(dest);
9127 1160500 }
9128
9129 998 eWallM::eWallM(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9130 998 {
9131 998 hashero=false;
9132 //nets+1000;
9133
1/4
✓ Branch 0 taken 998 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
998 if (SIZEflags != 0) init_size_flags();;
9134 998 }
9135
9136 504762 bool eWallM::animate(int32_t index)
9137 {
9138
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 504762 times.
504762 if(switch_hooked) return enemy::animate(index);
9139
2/4
✓ Branch 0 taken 504762 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 504762 times.
504762 if(fallclk||drownclk)
9140 {
9141 return enemy::animate(index);
9142 }
9143
2/2
✓ Branch 0 taken 9856 times.
✓ Branch 1 taken 494906 times.
504762 if(dying)
9144 9856 return Dead(index);
9145
9146
2/2
✓ Branch 0 taken 463930 times.
✓ Branch 1 taken 30976 times.
494906 if(clk==0)
9147 {
9148 30976 removearmos(x,y);
9149 30976 }
9150
9151 494906 hxofs=1000;
9152
2/2
✓ Branch 0 taken 117732 times.
✓ Branch 1 taken 377174 times.
494906 if(misc==0) //inside wall, ready to spawn?
9153 {
9154
4/4
✓ Branch 0 taken 228512 times.
✓ Branch 1 taken 148662 times.
✓ Branch 2 taken 16723 times.
✓ Branch 3 taken 211789 times.
377174 if(frame-wallm_load_clk>80 && clk>=0)
9155 {
9156 211789 int32_t wall=hero_on_wall();
9157 211789 int32_t wallm_cnt=0;
9158
9159
2/2
✓ Branch 0 taken 1670618 times.
✓ Branch 1 taken 211789 times.
1882407 for(int32_t i=0; i<guys.Count(); i++)
9160
2/2
✓ Branch 0 taken 657527 times.
✓ Branch 1 taken 1013091 times.
2683709 if(((enemy*)guys.spr(i))->type==eeWALLM)
9161 {
9162 1013091 int32_t m=((enemy*)guys.spr(i))->misc;
9163
9164
4/4
✓ Branch 0 taken 50104 times.
✓ Branch 1 taken 962987 times.
✓ Branch 2 taken 36738 times.
✓ Branch 3 taken 13366 times.
1013091 if(m && ((enemy*)guys.spr(i))->clk3==(wall^1))
9165 {
9166 13366 ++wallm_cnt;
9167 13366 }
9168 1013091 }
9169
9170
2/2
✓ Branch 0 taken 210948 times.
✓ Branch 1 taken 841 times.
211789 if(wall>0)
9171 {
9172 841 --wall;
9173 841 misc=1; //emerging from the wall?
9174 841 clk2=0;
9175 841 clk3=wall^1;
9176 841 wallm_load_clk=frame;
9177
9178
2/2
✓ Branch 0 taken 514 times.
✓ Branch 1 taken 327 times.
841 if(wall<=down)
9179 {
9180
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 423 times.
514 if(HeroDir()==left)
9181 91 dir=right;
9182 else
9183 423 dir=left;
9184 514 }
9185 else
9186 {
9187
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 261 times.
327 if(HeroDir()==up)
9188 66 dir=down;
9189 else
9190 261 dir=up;
9191 }
9192
9193
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 231 times.
✓ Branch 2 taken 283 times.
✓ Branch 3 taken 223 times.
✓ Branch 4 taken 104 times.
841 switch(wall)
9194 {
9195 case up:
9196 231 y=0;
9197 231 break;
9198
9199 case down:
9200 283 y=160;
9201 283 break;
9202
9203 case left:
9204 223 x=0;
9205 223 break;
9206
9207 case right:
9208 104 x=240;
9209 104 break;
9210 }
9211
9212
9213
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 261 times.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 423 times.
✓ Branch 4 taken 91 times.
841 switch(dir)
9214 {
9215 case up:
9216 261 y=(HeroY()+48-(wallm_cnt&1)*12);
9217 261 flip=wall&1;
9218 261 break;
9219
9220 case down:
9221 66 y=(HeroY()-48+(wallm_cnt&1)*12);
9222 66 flip=((wall&1)^1)+2;
9223 66 break;
9224
9225 case left:
9226 423 x=(HeroX()+48-(wallm_cnt&1)*12);
9227 423 flip=(wall==up?2:0)+1;
9228 423 break;
9229
9230 case right:
9231 91 x=(HeroX()-48+(wallm_cnt&1)*12);
9232 91 flip=(wall==up?2:0);
9233 91 break;
9234 }
9235
9236 841 }
9237 211789 }
9238 377174 }
9239 else
9240 117732 wallm_crawl();
9241
9242 494906 return enemy::animate(index);
9243 504762 }
9244
9245 117732 void eWallM::wallm_crawl()
9246 {
9247 117732 bool w=watch;
9248 117732 hxofs=0;
9249
9250
2/2
✓ Branch 0 taken 810 times.
✓ Branch 1 taken 116922 times.
117732 if(slide())
9251 {
9252 810 return;
9253 }
9254
9255 // if(dying || watch || (!hashero && stunclk))
9256
6/8
✓ Branch 0 taken 116922 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115593 times.
✓ Branch 3 taken 1329 times.
✓ Branch 4 taken 101047 times.
✓ Branch 5 taken 14546 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 101047 times.
116922 if(dying || (!hashero && ( stunclk || frozenclock )))
9257 {
9258 14546 return;
9259 }
9260
9261 102376 watch=false;
9262 102376 ++clk2;
9263 // Misc1: slightly different movement
9264 102376 float tmpmisc3 = ((40.0/(int32_t)dstep)*40);
9265
9266 //int32_t tmpmisc = int32_t((40.0/dstep)*40);
9267
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102376 times.
102376 misc=(clk2/(dmisc1==1?40:(int32_t)tmpmisc3))+1;
9268
5/6
✓ Branch 0 taken 6217 times.
✓ Branch 1 taken 96159 times.
✓ Branch 2 taken 4491 times.
✓ Branch 3 taken 1726 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4491 times.
102376 if(w&&misc>=3&&misc<=5)
9269 {
9270 4491 --clk2;
9271 4491 }
9272
9273
4/4
✓ Branch 0 taken 39396 times.
✓ Branch 1 taken 52852 times.
✓ Branch 2 taken 9984 times.
✓ Branch 3 taken 144 times.
102376 switch(misc)
9274 {
9275 case 1:
9276 case 2:
9277 52852 zc_swap(dir,clk3);
9278 52852 move(step);
9279 52852 zc_swap(dir,clk3);
9280 52852 break;
9281
9282 case 3:
9283 case 4:
9284 case 5:
9285
2/2
✓ Branch 0 taken 4491 times.
✓ Branch 1 taken 34905 times.
39396 if(w)
9286 {
9287 4491 watch=w;
9288 4491 return;
9289 }
9290
9291 34905 move(step);
9292 34905 break;
9293
9294 case 6:
9295 case 7:
9296 9984 zc_swap(dir,clk3);
9297 9984 dir^=1;
9298 9984 move(step);
9299 9984 dir^=1;
9300 9984 zc_swap(dir,clk3);
9301 9984 break;
9302
9303 default:
9304 144 misc=0;
9305 144 break;
9306 }
9307
9308 97885 watch=w;
9309 117732 }
9310
9311 9 void eWallM::grabhero()
9312 {
9313 9 hashero=true;
9314 9 superman=1;
9315 9 }
9316
9317 507147 void eWallM::draw(BITMAP *dest)
9318 {
9319 507147 dummy_bool[1]=hashero;
9320 507147 update_enemy_frame();
9321
9322
4/6
✓ Branch 0 taken 377966 times.
✓ Branch 1 taken 129181 times.
✓ Branch 2 taken 377966 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 377966 times.
507147 if(misc>0 || fallclk||drownclk)
9323 {
9324 129181 masked_draw(dest,16,playing_field_offset+16,224,144);
9325 129181 }
9326
9327 // enemy::draw(dest);
9328 // tile = clk&8 ? 128:129;
9329 507147 }
9330
9331 bool eWallM::isSubmerged() const
9332 {
9333 return ( !misc );
9334 }
9335
9336 1680 eTrap::eTrap(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9337 1680 {
9338
1/2
✓ Branch 0 taken 1680 times.
✗ Branch 1 not taken.
1680 ox=x; //original x
9339
1/2
✓ Branch 0 taken 1680 times.
✗ Branch 1 not taken.
1680 oy=y; //original y
9340
2/2
✓ Branch 0 taken 1474 times.
✓ Branch 1 taken 206 times.
1680 if(get_qr(qr_TRAPPOSFIX))
9341 {
9342
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 206 times.
✓ Branch 2 taken 206 times.
✗ Branch 3 not taken.
206 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
9343 206 }
9344
9345 1680 mainguy=false;
9346
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1680 times.
1680 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
9347 //nets+420;
9348 1680 dummy_int[1]=0;
9349
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1680 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1680 if (SIZEflags != 0) init_size_flags();;
9350 1680 }
9351
9352 1054519 bool eTrap::animate(int32_t index)
9353 {
9354
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1054519 times.
1054519 if(switch_hooked) return enemy::animate(index);
9355
2/4
✓ Branch 0 taken 1054519 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1054519 times.
1054519 if(fallclk||drownclk) return enemy::animate(index);
9356
2/2
✓ Branch 0 taken 1032785 times.
✓ Branch 1 taken 21734 times.
1054519 if(clk<0)
9357 21734 return enemy::animate(index);
9358
9359
2/2
✓ Branch 0 taken 967448 times.
✓ Branch 1 taken 65337 times.
1032785 if(clk==0)
9360 {
9361 65337 removearmos(x,y);
9362 65337 }
9363
9364
2/2
✓ Branch 0 taken 321964 times.
✓ Branch 1 taken 710821 times.
1032785 if(misc==0) // waiting
9365 {
9366 710821 ox = x;
9367 710821 oy = y;
9368 double _MSVC2022_tmp1, _MSVC2022_tmp2;
9369 710821 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
9370
9371
4/4
✓ Branch 0 taken 247420 times.
✓ Branch 1 taken 463401 times.
✓ Branch 2 taken 137375 times.
✓ Branch 3 taken 110045 times.
710821 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
9372 {
9373 110045 dir=down;
9374 110045 }
9375
4/4
✓ Branch 0 taken 398123 times.
✓ Branch 1 taken 202653 times.
✓ Branch 2 taken 137375 times.
✓ Branch 3 taken 260748 times.
600776 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
9376 {
9377 260748 dir=right;
9378 260748 }
9379
4/4
✓ Branch 0 taken 216363 times.
✓ Branch 1 taken 123665 times.
✓ Branch 2 taken 137375 times.
✓ Branch 3 taken 78988 times.
340028 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
9380 {
9381 78988 dir=up;
9382 78988 }
9383 else
9384 {
9385 261040 dir=left;
9386 }
9387
9388 710821 int32_t d2=lined_up(15,true);
9389
9390
4/4
✓ Branch 0 taken 272171 times.
✓ Branch 1 taken 438650 times.
✓ Branch 2 taken 1110486 times.
✓ Branch 3 taken 399665 times.
1107466 if(((d2<left || d2 > right) && (dmisc1==1)) ||
9391
2/2
✓ Branch 0 taken 234727 times.
✓ Branch 1 taken 164938 times.
399665 ((d2>down) && (dmisc1==2)) ||
9392
2/2
✓ Branch 0 taken 187069 times.
✓ Branch 1 taken 31043 times.
164938 ((d2>right) && (!dmisc1)) ||
9393
2/2
✓ Branch 0 taken 396645 times.
✓ Branch 1 taken 178533 times.
218112 ((d2<l_up) && (dmisc1==4)) ||
9394
3/4
✓ Branch 0 taken 396645 times.
✓ Branch 1 taken 218112 times.
✓ Branch 2 taken 396645 times.
✗ Branch 3 not taken.
178533 ((d2!=r_up) && (d2!=l_down) && (dmisc1==6)) ||
9395
3/4
✓ Branch 0 taken 396645 times.
✓ Branch 1 taken 178533 times.
✓ Branch 2 taken 396645 times.
✗ Branch 3 not taken.
218112 ((d2!=l_up) && (d2!=r_down) && (dmisc1==8)))
9396 {
9397 2535148 d2=-1;
9398 2535148 }
9399
9400
4/4
✓ Branch 0 taken 20966 times.
✓ Branch 1 taken 471743 times.
✓ Branch 2 taken 18829 times.
✓ Branch 3 taken 2137 times.
492709 if(d2!=-1 && trapmove(d2))
9401 {
9402 2137 dir=d2;
9403 2137 misc=1;
9404 2137 clk2=(dir==down)?3:0;
9405 2137 }
9406 492709 }
9407
9408
2/2
✓ Branch 0 taken 724331 times.
✓ Branch 1 taken 90342 times.
814673 if(misc==1) // charging
9409 {
9410 90342 clk2=(clk2+1)&3;
9411 90342 step=(clk2==3)?1:2;
9412
9413
4/4
✓ Branch 0 taken 89516 times.
✓ Branch 1 taken 826 times.
✓ Branch 2 taken 1105 times.
✓ Branch 3 taken 88411 times.
90342 if(!trapmove(dir) || clip())
9414 {
9415 1931 misc=2;
9416
9417
1/2
✓ Branch 0 taken 1931 times.
✗ Branch 1 not taken.
1931 if(dir<l_up)
9418 {
9419 1931 dir=dir^1;
9420 1931 }
9421 else
9422 {
9423 dir=dir^3;
9424 }
9425 1931 }
9426 else
9427 {
9428 88411 sprite::move(step);
9429 }
9430 90342 }
9431
9432
2/2
✓ Branch 0 taken 578983 times.
✓ Branch 1 taken 235690 times.
814673 if(misc==2) // retreating
9433 {
9434 235690 step=(++clk2&1)?1:0;
9435
9436
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 39305 times.
✓ Branch 2 taken 81283 times.
✓ Branch 3 taken 29536 times.
✓ Branch 4 taken 85566 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
235690 switch(dir)
9437 {
9438 case up:
9439
2/2
✓ Branch 0 taken 275 times.
✓ Branch 1 taken 39030 times.
39305 if(int32_t(y)<=oy) goto trap_rest;
9440 39030 else sprite::move(step);
9441
9442 39030 break;
9443
9444 case left:
9445
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 80889 times.
81283 if(int32_t(x)<=ox) goto trap_rest;
9446 80889 else sprite::move(step);
9447
9448 80889 break;
9449
9450 case down:
9451
2/2
✓ Branch 0 taken 226 times.
✓ Branch 1 taken 29310 times.
29536 if(int32_t(y)>=oy) goto trap_rest;
9452 29310 else sprite::move(step);
9453
9454 29310 break;
9455
9456 case right:
9457
2/2
✓ Branch 0 taken 439 times.
✓ Branch 1 taken 85127 times.
85566 if(int32_t(x)>=ox) goto trap_rest;
9458 85127 else sprite::move(step);
9459
9460 85127 break;
9461
9462 case l_up:
9463 if(int32_t(x)<=ox && int32_t(y)<=oy) goto trap_rest;
9464 else sprite::move(step);
9465
9466 break;
9467
9468 case r_up:
9469 if(int32_t(x)>=ox && int32_t(y)<=oy) goto trap_rest;
9470 else sprite::move(step);
9471
9472 break;
9473
9474 case l_down:
9475 if(int32_t(x)<=ox && int32_t(y)>=oy) goto trap_rest;
9476 else sprite::move(step);
9477
9478 break;
9479
9480 case r_down:
9481 if(int32_t(x)>=ox && int32_t(y)>=oy) goto trap_rest;
9482 else sprite::move(step);
9483
9484 break;
9485 trap_rest:
9486 {
9487 1334 x=ox;
9488 1334 y=oy;
9489 1334 misc=0;
9490 }
9491 1334 }
9492 235690 }
9493
9494 814673 return enemy::animate(index);
9495 836407 }
9496
9497 111308 bool eTrap::trapmove(int32_t ndir)
9498 {
9499
2/2
✓ Branch 0 taken 81544 times.
✓ Branch 1 taken 29764 times.
111308 if(get_qr(qr_MEANTRAPS))
9500 {
9501 81544 mapscr* scr = get_scr(screen_spawned);
9502
2/2
✓ Branch 0 taken 1340 times.
✓ Branch 1 taken 80204 times.
81544 if(scr->flags2&fFLOATTRAPS)
9503 1340 return canmove(ndir,(zfix)1,spw_floater, 0, 0, 15, 15,false);
9504
9505 80204 return canmove(ndir,(zfix)1,spw_water, 0, 0, 15, 15,false);
9506 }
9507
9508
6/6
✓ Branch 0 taken 14672 times.
✓ Branch 1 taken 15092 times.
✓ Branch 2 taken 7198 times.
✓ Branch 3 taken 7474 times.
✓ Branch 4 taken 2468 times.
✓ Branch 5 taken 4730 times.
29764 if(oy==80 && !(ndir==left || ndir == right))
9509 4730 return false;
9510
9511
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 25034 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
25034 if(ox==128 && !(ndir==up || ndir==down))
9512 return false;
9513
9514
3/4
✓ Branch 0 taken 7496 times.
✓ Branch 1 taken 17538 times.
✓ Branch 2 taken 7496 times.
✗ Branch 3 not taken.
25034 if(oy<80 && ndir==up)
9515 return false;
9516
9517
3/4
✓ Branch 0 taken 7596 times.
✓ Branch 1 taken 17438 times.
✓ Branch 2 taken 7596 times.
✗ Branch 3 not taken.
25034 if(oy>80 && ndir==down)
9518 return false;
9519
9520
4/4
✓ Branch 0 taken 14455 times.
✓ Branch 1 taken 10579 times.
✓ Branch 2 taken 9733 times.
✓ Branch 3 taken 4722 times.
25034 if(ox<128 && ndir==left)
9521 4722 return false;
9522
9523
4/4
✓ Branch 0 taken 10579 times.
✓ Branch 1 taken 9733 times.
✓ Branch 2 taken 9866 times.
✓ Branch 3 taken 713 times.
20312 if(ox>128 && ndir==right)
9524 713 return false;
9525
9526
5/6
✓ Branch 0 taken 9733 times.
✓ Branch 1 taken 9866 times.
✓ Branch 2 taken 4067 times.
✓ Branch 3 taken 5666 times.
✓ Branch 4 taken 4067 times.
✗ Branch 5 not taken.
19599 if(ox<128 && oy<80 && ndir==l_up)
9527 return false;
9528
9529
5/6
✓ Branch 0 taken 9733 times.
✓ Branch 1 taken 9866 times.
✓ Branch 2 taken 3911 times.
✓ Branch 3 taken 5822 times.
✓ Branch 4 taken 3911 times.
✗ Branch 5 not taken.
19599 if(ox<128 && oy>80 && ndir==l_down)
9530 return false;
9531
9532
5/6
✓ Branch 0 taken 9866 times.
✓ Branch 1 taken 9733 times.
✓ Branch 2 taken 3429 times.
✓ Branch 3 taken 6437 times.
✓ Branch 4 taken 3429 times.
✗ Branch 5 not taken.
19599 if(ox>128 && oy<80 && ndir==r_up)
9533 return false;
9534
9535
5/6
✓ Branch 0 taken 9866 times.
✓ Branch 1 taken 9733 times.
✓ Branch 2 taken 3685 times.
✓ Branch 3 taken 6181 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3685 times.
19599 if(ox>128 && oy>80 && ndir==r_down)
9536 return false;
9537
9538 19599 return true;
9539 111308 }
9540
9541 89516 bool eTrap::clip()
9542 {
9543
2/2
✓ Branch 0 taken 43022 times.
✓ Branch 1 taken 46494 times.
89516 if(get_qr(qr_MEANPLACEDTRAPS))
9544 {
9545
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 5954 times.
✓ Branch 2 taken 8764 times.
✓ Branch 3 taken 16437 times.
✓ Branch 4 taken 15339 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
46494 switch(dir)
9546 {
9547 case up:
9548
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5954 times.
5954 if(y<=0) return true;
9549
9550 5954 break;
9551
9552 case down:
9553
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8764 times.
8764 if(y>=world_h-16) return true;
9554
9555 8764 break;
9556
9557 case left:
9558
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16437 times.
16437 if(x<=0) return true;
9559
9560 16437 break;
9561
9562 case right:
9563
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15339 times.
15339 if(x>=world_w-16) return true;
9564
9565 15339 break;
9566
9567 case l_up:
9568 if(y<=0||x<=0) return true;
9569
9570 break;
9571
9572 case l_down:
9573 if(y>=world_h-16||x<=0) return true;
9574
9575 break;
9576
9577 case r_up:
9578 if(y<=0||x>=world_w-16) return true;
9579
9580 break;
9581
9582 case r_down:
9583 if(y>=world_h-16||x>=world_w-16) return true;
9584
9585 break;
9586 }
9587
9588 46494 return false;
9589 }
9590 else
9591 {
9592
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 4882 times.
✓ Branch 2 taken 5449 times.
✓ Branch 3 taken 16755 times.
✓ Branch 4 taken 15936 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
43022 switch(dir)
9593 {
9594 case up:
9595
4/4
✓ Branch 0 taken 4828 times.
✓ Branch 1 taken 54 times.
✓ Branch 2 taken 4641 times.
✓ Branch 3 taken 187 times.
4882 if(oy>80 && y<=86) return true;
9596
9597 4695 break;
9598
9599 case down:
9600
4/4
✓ Branch 0 taken 5368 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 5172 times.
✓ Branch 3 taken 196 times.
5449 if(oy<80 && y>=80) return true;
9601
9602 5253 break;
9603
9604 case left:
9605
4/4
✓ Branch 0 taken 16665 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 16286 times.
✓ Branch 3 taken 379 times.
16755 if(ox>128 && x<=124) return true;
9606
9607 16376 break;
9608
9609 case right:
9610
4/4
✓ Branch 0 taken 15855 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 15512 times.
✓ Branch 3 taken 343 times.
15936 if(ox<120 && x>=116) return true;
9611
9612 15593 break;
9613
9614 case l_up:
9615 if(oy>80 && y<=86 && ox>128 && x<=124) return true;
9616
9617 break;
9618
9619 case l_down:
9620 if(oy<80 && y>=80 && ox>128 && x<=124) return true;
9621
9622 break;
9623
9624 case r_up:
9625 if(oy>80 && y<=86 && ox<120 && x>=116) return true;
9626
9627 break;
9628
9629 case r_down:
9630 if(oy<80 && y>=80 && ox<120 && x>=116) return true;
9631
9632 break;
9633 }
9634
9635 41917 return false;
9636 }
9637 89516 }
9638
9639 1073433 void eTrap::draw(BITMAP *dest)
9640 {
9641 1073433 update_enemy_frame();
9642 1073433 enemy::draw(dest);
9643 1073433 }
9644
9645 5755 int32_t eTrap::takehit(weapon*,weapon*)
9646 {
9647 5755 return 0;
9648 }
9649
9650 893 eTrap2::eTrap2(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9651 893 {
9652 893 lasthit=-1;
9653 893 lasthitclk=0;
9654 893 mainguy=false;
9655
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 893 times.
893 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
9656
1/2
✓ Branch 0 taken 893 times.
✗ Branch 1 not taken.
893 step=2;
9657
3/6
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 436 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 457 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
893 if(dmisc1==1 || (dmisc1==0 && zc_oldrand()&2))
9658 {
9659
2/4
✓ Branch 0 taken 436 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 436 times.
✗ Branch 3 not taken.
436 dir=(x<=112)?right:left;
9660 436 }
9661 else
9662 {
9663
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 dir=(y<=72)?down:up;
9664 }
9665
9666
2/2
✓ Branch 0 taken 760 times.
✓ Branch 1 taken 133 times.
893 if(get_qr(qr_TRAPPOSFIX))
9667 {
9668
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 133 times.
✓ Branch 2 taken 133 times.
✗ Branch 3 not taken.
133 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
9669 133 }
9670
9671 //nets+((id==eTRAP_LR)?540:520);
9672 893 dummy_int[1]=0;
9673
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 893 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
893 if (SIZEflags != 0) init_size_flags();;
9674 893 }
9675
9676 370041 bool eTrap2::animate(int32_t index)
9677 {
9678
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 370041 times.
370041 if(switch_hooked) return enemy::animate(index);
9679
2/4
✓ Branch 0 taken 370041 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 370041 times.
370041 if(fallclk||drownclk) return enemy::animate(index);
9680
2/2
✓ Branch 0 taken 358893 times.
✓ Branch 1 taken 11148 times.
370041 if(clk<0)
9681 11148 return enemy::animate(index);
9682
9683
2/2
✓ Branch 0 taken 22873 times.
✓ Branch 1 taken 336020 times.
358893 if(clk==0)
9684 {
9685 22873 removearmos(x,y);
9686 22873 }
9687
9688
2/2
✓ Branch 0 taken 234567 times.
✓ Branch 1 taken 124326 times.
358893 if(!get_qr(qr_PHANTOMPLACEDTRAPS))
9689 {
9690
2/2
✓ Branch 0 taken 11074 times.
✓ Branch 1 taken 113252 times.
124326 if(lasthitclk>0)
9691 {
9692 11074 --lasthitclk;
9693 11074 }
9694 else
9695 {
9696 113252 lasthit=-1;
9697 }
9698
9699 124326 bool hitenemy=false;
9700
9701
2/2
✓ Branch 0 taken 864860 times.
✓ Branch 1 taken 124326 times.
989186 for(int32_t j=0; j<guys.Count(); j++)
9702 {
9703
4/4
✓ Branch 0 taken 740534 times.
✓ Branch 1 taken 124326 times.
✓ Branch 2 taken 10183 times.
✓ Branch 3 taken 730351 times.
864860 if((j!=index) && (lasthit!=j))
9704 {
9705
2/2
✓ Branch 0 taken 726682 times.
✓ Branch 1 taken 3669 times.
730351 if(hit(guys.spr(j)))
9706 {
9707 3669 lasthit=j;
9708 3669 lasthitclk=10;
9709 3669 hitenemy=true;
9710 3669 guys.spr(j)->lasthit=index;
9711 3669 guys.spr(j)->lasthitclk=10;
9712 // guys.spr(j)->dir=guys.spr(j)->dir^1;
9713 3669 }
9714 730351 }
9715 864860 }
9716
9717
5/6
✓ Branch 0 taken 121171 times.
✓ Branch 1 taken 3155 times.
✓ Branch 2 taken 121171 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2831 times.
✓ Branch 5 taken 118340 times.
124326 if(!trapmove(dir) || clip() || hitenemy)
9718 {
9719
3/4
✓ Branch 0 taken 2831 times.
✓ Branch 1 taken 3155 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2831 times.
5986 if(!trapmove(dir) || clip())
9720 {
9721 3155 lasthit=-1;
9722 3155 lasthitclk=0;
9723 3155 }
9724
9725
2/2
✓ Branch 0 taken 5624 times.
✓ Branch 1 taken 362 times.
5986 if(get_qr(qr_MORESOUNDS))
9726 362 sfx(WAV_ZN1TAP,pan(x));
9727
9728 5986 dir=dir^1;
9729 5986 }
9730
9731 124326 sprite::move(step);
9732 124326 }
9733 else
9734 {
9735
3/4
✓ Branch 0 taken 226871 times.
✓ Branch 1 taken 7696 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 226871 times.
234567 if(!trapmove(dir) || clip())
9736 {
9737
2/2
✓ Branch 0 taken 5398 times.
✓ Branch 1 taken 2298 times.
7696 if(get_qr(qr_MORESOUNDS))
9738 2298 sfx(WAV_ZN1TAP,pan(x));
9739
9740 7696 dir=dir^1;
9741 7696 }
9742
9743 234567 sprite::move(step);
9744 }
9745
9746 358893 return enemy::animate(index);
9747 370041 }
9748
9749 364879 bool eTrap2::trapmove(int32_t ndir)
9750 {
9751 364879 mapscr* scr = get_scr(screen_spawned);
9752
2/2
✓ Branch 0 taken 1878 times.
✓ Branch 1 taken 363001 times.
364879 if(scr->flags2&fFLOATTRAPS)
9753 1878 return canmove(ndir,(zfix)1,spw_floater, 0, 0, 15, 15,false);
9754
9755 363001 return canmove(ndir,(zfix)1,spw_water, 0, 0, 15, 15,false);
9756 364879 }
9757
9758 350873 bool eTrap2::clip()
9759 {
9760
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 94187 times.
✓ Branch 2 taken 94862 times.
✓ Branch 3 taken 80685 times.
✓ Branch 4 taken 81139 times.
350873 switch(dir)
9761 {
9762 case up:
9763
1/2
✓ Branch 0 taken 94187 times.
✗ Branch 1 not taken.
94187 if(y<=0) return true;
9764
9765 94187 break;
9766
9767 case down:
9768
1/2
✓ Branch 0 taken 94862 times.
✗ Branch 1 not taken.
94862 if(y>=world_h-16) return true;
9769
9770 94862 break;
9771
9772 case left:
9773
1/2
✓ Branch 0 taken 80685 times.
✗ Branch 1 not taken.
80685 if(x<=0) return true;
9774
9775 80685 break;
9776
9777 case right:
9778
1/2
✓ Branch 0 taken 81139 times.
✗ Branch 1 not taken.
81139 if(x>=world_w-16) return true;
9779
9780 81139 break;
9781 }
9782
9783 350873 return false;
9784 350873 }
9785
9786 375587 void eTrap2::draw(BITMAP *dest)
9787 {
9788 375587 update_enemy_frame();
9789 375587 enemy::draw(dest);
9790 375587 }
9791
9792 3281 int32_t eTrap2::takehit(weapon*,weapon*)
9793 {
9794 3281 return 0;
9795 }
9796
9797 354 eRock::eRock(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9798 354 {
9799 //do not show "enemy appering" anim -DD
9800 354 clk=0;
9801 354 mainguy=false;
9802 354 clk2=-14;
9803 //Enemy Editor Size Tab
9804
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 init_size_flags();
9805 //nets+1640;
9806 354 }
9807
9808 354 void eRock::init_size_flags()
9809 {
9810
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
354 if ((d->SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
9811 354 else hxofs = -2;
9812
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
354 if ((d->SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
9813 354 else hyofs = -2;
9814
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
354 if (((d->SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
9815 354 else hit_width = 20;
9816
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
354 if (((d->SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
9817 354 else hit_height = 20;
9818
9819
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
354 if (((d->SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
9820
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
354 if (((d->SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
9821
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
354 if (((d->SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
9822
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 if ((d->SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
9823
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 if ((d->SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
9824 {
9825 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
9826 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
9827 }
9828
9829
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 if ((d->SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
9830 354 }
9831
9832 121997 bool eRock::animate(int32_t index)
9833 {
9834
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 121997 times.
121997 if(switch_hooked) return enemy::animate(index);
9835
2/4
✓ Branch 0 taken 121997 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 121997 times.
121997 if(fallclk||drownclk) return enemy::animate(index);
9836
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 121997 times.
121997 if(dying)
9837 return Dead(index);
9838
9839
2/2
✓ Branch 0 taken 113621 times.
✓ Branch 1 taken 8376 times.
121997 if(clk==0)
9840 {
9841 8376 removearmos(x,y);
9842 8376 }
9843
9844
2/2
✓ Branch 0 taken 121300 times.
✓ Branch 1 taken 697 times.
121997 if(++clk2==0) // start it
9845 {
9846 697 x=zc_oldrand()&0xF0;
9847 697 y=0;
9848 697 clk3=0;
9849 697 clk2=zc_oldrand()&15;
9850 697 }
9851
9852
2/2
✓ Branch 0 taken 22820 times.
✓ Branch 1 taken 99177 times.
121997 if(clk2>16) // move it
9853 {
9854
2/2
✓ Branch 0 taken 95747 times.
✓ Branch 1 taken 3430 times.
99177 if(clk3<=0) // start bounce
9855 {
9856 3430 dir=zc_oldrand()&1;
9857
9858
2/2
✓ Branch 0 taken 3063 times.
✓ Branch 1 taken 367 times.
3430 if(x<32) dir=1;
9859
9860
2/2
✓ Branch 0 taken 3133 times.
✓ Branch 1 taken 297 times.
3430 if(x>208) dir=0;
9861 3430 }
9862
9863
2/2
✓ Branch 0 taken 95993 times.
✓ Branch 1 taken 3184 times.
99177 if(clk3<13+16)
9864 {
9865 95993 x += dir ? 1 : -1; //right, left
9866 95993 dummy_int[1]=dir;
9867
9868
2/2
✓ Branch 0 taken 6852 times.
✓ Branch 1 taken 89141 times.
95993 if(clk3<2)
9869 {
9870 6852 y-=2; //up
9871 6852 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
9872 6852 }
9873
2/2
✓ Branch 0 taken 10208 times.
✓ Branch 1 taken 78933 times.
89141 else if(clk3<5)
9874 {
9875 10208 y--; //up
9876 10208 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
9877 10208 }
9878
2/2
✓ Branch 0 taken 10135 times.
✓ Branch 1 taken 68798 times.
78933 else if(clk3<8)
9879 {
9880 10135 dummy_int[2]=(dummy_int[1]==1)?right:left;
9881 10135 }
9882
2/2
✓ Branch 0 taken 10058 times.
✓ Branch 1 taken 58740 times.
68798 else if(clk3<11)
9883 {
9884 10058 y++; //down
9885 10058 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
9886 10058 }
9887 else
9888 {
9889 58740 y+=2; //down
9890 58740 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
9891 }
9892
9893 95993 ++clk3;
9894 95993 }
9895
2/2
✓ Branch 0 taken 2761 times.
✓ Branch 1 taken 423 times.
3184 else if(y<world_h)
9896 2761 clk3=0; // next bounce
9897 else
9898 423 clk2 = -(zc_oldrand()&63); // back to top
9899 99177 }
9900
9901 121997 return enemy::animate(index);
9902 121997 }
9903
9904 51441 bool eRock::can_drawshadow() const
9905 {
9906
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51441 times.
51441 if(shadow_overpit())
9907 return false;
9908
9909 51441 return clk2>=0;
9910 51441 }
9911 51441 void eRock::drawshadow(BITMAP *dest, bool translucent)
9912 {
9913
2/2
✓ Branch 0 taken 7191 times.
✓ Branch 1 taken 44250 times.
51441 if(!can_drawshadow())
9914 7191 return;
9915 44250 int32_t tempy=yofs;
9916 44250 flip = 0;
9917 44250 int32_t fdiv = frate/4;
9918
1/2
✓ Branch 0 taken 44250 times.
✗ Branch 1 not taken.
44250 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
9919
1/2
✓ Branch 0 taken 44250 times.
✗ Branch 1 not taken.
44250 int32_t f2=get_qr(qr_NEWENEMYTILES)?
9920 44250 efrate:((clk>=(frate>>1))?1:0);
9921 44250 shadowtile = wpnsbuf[spr_shadow].tile+f2;
9922
9923 44250 yofs+=8;
9924
6/6
✓ Branch 0 taken 20474 times.
✓ Branch 1 taken 23776 times.
✓ Branch 2 taken 38962 times.
✓ Branch 3 taken 5288 times.
✓ Branch 4 taken 19073 times.
✓ Branch 5 taken 19889 times.
44250 yofs+=zc_max(0,zc_min(29-clk3,clk3));
9925 44250 sprite::drawshadow(dest, translucent);
9926 44250 yofs=tempy;
9927 51441 }
9928
9929 122078 void eRock::draw(BITMAP *dest)
9930 {
9931
4/6
✓ Branch 0 taken 17035 times.
✓ Branch 1 taken 105043 times.
✓ Branch 2 taken 17035 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 17035 times.
122078 if(clk2>=0 || fallclk||drownclk)
9932 {
9933 105043 int32_t tempdir=dir;
9934 105043 dir=dummy_int[2];
9935 105043 update_enemy_frame();
9936 105043 enemy::draw(dest);
9937 105043 dir=tempdir;
9938 105043 }
9939 122078 }
9940
9941 1014 int32_t eRock::takehit(weapon*,weapon*)
9942 {
9943 1014 return 0;
9944 }
9945
9946 30 eBoulder::eBoulder(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9947 30 {
9948 30 clk=0;
9949 30 mainguy=false;
9950 30 clk2=-14;
9951
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 init_size_flags();
9952 //nets+1680;
9953 30 }
9954
9955 4440 bool eBoulder::animate(int32_t index)
9956 {
9957
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
4440 if(switch_hooked) return enemy::animate(index);
9958
2/4
✓ Branch 0 taken 4440 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4440 times.
4440 if(fallclk||drownclk) return enemy::animate(index);
9959
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
4440 if(dying)
9960 return Dead(index);
9961
9962
2/2
✓ Branch 0 taken 4150 times.
✓ Branch 1 taken 290 times.
4440 if(clk==0)
9963 {
9964 290 removearmos(x,y);
9965 290 }
9966
9967 zfix *vert;
9968
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
✓ Branch 2 taken 4440 times.
✗ Branch 3 not taken.
4440 vert = (moveflags & move_use_fake_z) ? &fakez : get_qr(qr_ENEMIESZAXIS) ? &z : &y;
9969
9970
2/2
✓ Branch 0 taken 4408 times.
✓ Branch 1 taken 32 times.
4440 if(++clk2==0) // start it
9971 {
9972 32 x=zc_oldrand()&0xF0;
9973 32 y=-32;
9974 32 clk3=0;
9975 32 clk2=zc_oldrand()&15;
9976 32 }
9977
9978
2/2
✓ Branch 0 taken 842 times.
✓ Branch 1 taken 3598 times.
4440 if(clk2>16) // move it
9979 {
9980
2/2
✓ Branch 0 taken 3467 times.
✓ Branch 1 taken 131 times.
3598 if(clk3<=0) // start bounce
9981 {
9982 131 dir=zc_oldrand()&1;
9983
9984
2/2
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 10 times.
131 if(x<32) dir=1;
9985
9986
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
131 if(x>208) dir=0;
9987 131 }
9988
9989
2/2
✓ Branch 0 taken 3487 times.
✓ Branch 1 taken 111 times.
3598 if(clk3<13+16)
9990 {
9991 3487 x += dir ? 1 : -1; //right, left
9992 3487 dummy_int[1]=dir;
9993
9994
2/2
✓ Branch 0 taken 261 times.
✓ Branch 1 taken 3226 times.
3487 if(clk3<2)
9995 {
9996 261 y-=2; //up
9997 261 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
9998 261 }
9999
2/2
✓ Branch 0 taken 382 times.
✓ Branch 1 taken 2844 times.
3226 else if(clk3<5)
10000 {
10001 382 y--; //up
10002 382 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
10003 382 }
10004
2/2
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 2468 times.
2844 else if(clk3<8)
10005 {
10006 376 dummy_int[2]=(dummy_int[1]==1)?right:left;
10007 376 }
10008
2/2
✓ Branch 0 taken 367 times.
✓ Branch 1 taken 2101 times.
2468 else if(clk3<11)
10009 {
10010 367 y++; //down
10011 367 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
10012 367 }
10013 else
10014 {
10015 2101 y+=2; //down
10016 2101 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
10017 }
10018
10019 3487 ++clk3;
10020 3487 }
10021
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 10 times.
111 else if(y<176)
10022 101 clk3=0; // next bounce
10023 else
10024 10 clk2 = -(zc_oldrand()&63); // back to top
10025 3598 }
10026
10027 4440 return enemy::animate(index);
10028 4440 }
10029
10030 4440 bool eBoulder::can_drawshadow() const
10031 {
10032
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
4440 if(shadow_overpit())
10033 return false;
10034
10035 4440 return clk2>=0;
10036 4440 }
10037 4440 void eBoulder::drawshadow(BITMAP *dest, bool translucent)
10038 {
10039
2/2
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 3868 times.
4440 if(!can_drawshadow())
10040 572 return;
10041 3868 int32_t tempy=yofs;
10042 3868 flip = 0;
10043 3868 int32_t f2=((clk<<2)/frate)<<1;
10044 3868 shadowtile = wpnsbuf[spr_shadow].tile+f2;
10045
6/6
✓ Branch 0 taken 1729 times.
✓ Branch 1 taken 2139 times.
✓ Branch 2 taken 3356 times.
✓ Branch 3 taken 512 times.
✓ Branch 4 taken 1618 times.
✓ Branch 5 taken 1738 times.
3868 yofs+=zc_max(0,zc_min(29-clk3,clk3));
10046
10047 3868 yofs+=8;
10048 3868 xofs-=8;
10049 3868 sprite::drawshadow(dest, translucent);
10050 3868 xofs+=16;
10051 3868 ++shadowtile;
10052 3868 sprite::drawshadow(dest, translucent);
10053 3868 yofs+=16;
10054 3868 shadowtile+=20;
10055 3868 sprite::drawshadow(dest, translucent);
10056 3868 xofs-=16;
10057 3868 --shadowtile;
10058 3868 sprite::drawshadow(dest, translucent);
10059 3868 xofs+=8;
10060 3868 yofs=tempy;
10061 4440 }
10062
10063 4440 void eBoulder::draw(BITMAP *dest)
10064 {
10065
4/6
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 3868 times.
✓ Branch 2 taken 572 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 572 times.
4440 if(clk2>=0 || fallclk||drownclk)
10066 {
10067 3868 int32_t tempdir=dir;
10068 3868 dir=dummy_int[2];
10069 3868 update_enemy_frame();
10070 3868 dir=tempdir;
10071 3868 xofs-=8;
10072 3868 yofs-=8;
10073 3868 drawblock(dest,15);
10074 3868 xofs+=8;
10075 3868 yofs+=8;
10076 // enemy::draw(dest);
10077 3868 }
10078 4440 }
10079
10080 30 void eBoulder::init_size_flags()
10081 {
10082
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ((d->SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
10083 30 else hxofs = -10;
10084
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ((d->SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
10085 30 else hyofs = -10;
10086
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
10087 30 else hit_width = 36;
10088
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
10089 30 else hit_height = 36;
10090
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
10091 30 else hzsz = 16; //can't be jumped
10092
10093
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30 if (((d->SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10094
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30 if (((d->SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
10095
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
10096
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if ((d->SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
10097
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if ((d->SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
10098 {
10099 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10100 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
10101 }
10102
10103
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if ((d->SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
10104 30 }
10105
10106 int32_t eBoulder::takehit(weapon*,weapon*)
10107 {
10108 return 0;
10109 }
10110
10111 4433 eProjectile::eProjectile(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk),
10112
2/2
✓ Branch 0 taken 535 times.
✓ Branch 1 taken 3898 times.
4433 minRange(get_qr(qr_BROKENSTATUES) ? 0 : Clk)
10113 4433 {
10114 /* fixing
10115 hp=1;
10116 */
10117 4433 mainguy=false;
10118
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 4426 times.
4433 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10119 4433 hclk=clk; // the "no fire" range
10120 4433 clk=0;
10121 4433 clk3=96;
10122 4433 timer=0;
10123
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 4415 times.
4433 if(o_tile==0)
10124 {
10125 4415 superman=1;
10126 4415 hxofs=1000;
10127 4415 }
10128
1/4
✓ Branch 0 taken 4433 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4433 if (SIZEflags != 0) init_size_flags();;
10129 4433 }
10130
10131 2505003 bool eProjectile::animate(int32_t index)
10132 {
10133
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2505003 times.
2505003 if(switch_hooked) return enemy::animate(index);
10134
2/4
✓ Branch 0 taken 2505003 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2505003 times.
2505003 if(fallclk||drownclk) return enemy::animate(index);
10135
2/2
✓ Branch 0 taken 2492673 times.
✓ Branch 1 taken 12330 times.
2505003 if(clk==0)
10136 {
10137 12330 removearmos(x,y);
10138 12330 }
10139
10140 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10141 2505003 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10142
10143
4/4
✓ Branch 0 taken 835608 times.
✓ Branch 1 taken 1669395 times.
✓ Branch 2 taken 431977 times.
✓ Branch 3 taken 403631 times.
2505003 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
10144 {
10145 403631 dir=down;
10146 403631 }
10147
4/4
✓ Branch 0 taken 1349154 times.
✓ Branch 1 taken 752218 times.
✓ Branch 2 taken 431977 times.
✓ Branch 3 taken 917177 times.
2101372 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
10148 {
10149 917177 dir=right;
10150 917177 }
10151
4/4
✓ Branch 0 taken 790877 times.
✓ Branch 1 taken 393318 times.
✓ Branch 2 taken 431977 times.
✓ Branch 3 taken 358900 times.
1184195 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
10152 {
10153 358900 dir=up;
10154 358900 }
10155 else
10156 {
10157 825295 dir=left;
10158 }
10159
10160
3/4
✓ Branch 0 taken 2505003 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1306384 times.
✓ Branch 3 taken 1198619 times.
2505003 if(!stunclk && ++clk3>80)
10161 {
10162
2/2
✓ Branch 0 taken 1046 times.
✓ Branch 1 taken 1197573 times.
1198619 if(dmisc1==9) // Breath type
10163 {
10164
2/2
✓ Branch 0 taken 483 times.
✓ Branch 1 taken 563 times.
1046 if(timer==0)
10165 {
10166 563 unsigned r=zc_oldrand();
10167
10168
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 557 times.
563 if(!(r&63))
10169 {
10170 6 timer=zc_oldrand()%50+50;
10171 6 }
10172 563 }
10173
10174
2/2
✓ Branch 0 taken 557 times.
✓ Branch 1 taken 489 times.
1046 if(timer>0)
10175 {
10176
2/2
✓ Branch 0 taken 370 times.
✓ Branch 1 taken 119 times.
489 if(timer%4==0)
10177 {
10178 119 FireBreath(false);
10179 119 }
10180
10181
2/2
✓ Branch 0 taken 483 times.
✓ Branch 1 taken 6 times.
489 if(--timer==0)
10182 {
10183 6 clk3=0;
10184 6 }
10185 489 }
10186 1046 }
10187
10188 else // Not breath type
10189 {
10190 1197573 unsigned r=zc_oldrand();
10191
10192
4/4
✓ Branch 0 taken 18811 times.
✓ Branch 1 taken 1178762 times.
✓ Branch 2 taken 1266 times.
✓ Branch 3 taken 17545 times.
1197573 if(!(r&63) && !HeroInRange(minRange))
10193 {
10194 17545 FireWeapon();
10195
10196
4/4
✓ Branch 0 taken 15040 times.
✓ Branch 1 taken 2505 times.
✓ Branch 2 taken 186 times.
✓ Branch 3 taken 66 times.
17797 if(get_qr(qr_BROKENSTATUES)==0 &&
10197
3/4
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 14788 times.
✓ Branch 2 taken 252 times.
✗ Branch 3 not taken.
15040 ((wpn==ewFireball || wpn==ewFireball2) || dmisc1==e1tNORMAL))
10198 {
10199
2/2
✓ Branch 0 taken 13945 times.
✓ Branch 1 taken 909 times.
14854 if(!((r>>7)&15))
10200 {
10201 909 x-=4;
10202 909 FireWeapon();
10203 909 x+=4;
10204 909 }
10205 14854 }
10206
10207 17545 clk3=0;
10208 17545 }
10209 }
10210 1198619 }
10211
10212 2505003 return enemy::animate(index);
10213 2505003 }
10214
10215 2520592 void eProjectile::draw(BITMAP *dest)
10216 {
10217 2520592 update_enemy_frame();
10218 2520592 enemy::draw(dest);
10219 2520592 }
10220
10221 533 eTrigger::eTrigger(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10222 533 {
10223 533 hxofs=1000;
10224 533 }
10225
10226 249811 void eTrigger::draw(BITMAP *dest)
10227 {
10228 249811 update_enemy_frame();
10229 249811 enemy::draw(dest);
10230 249811 }
10231
10232 void eTrigger::death_sfx()
10233 {
10234 //silent death
10235 }
10236
10237 5 eNPC::eNPC(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10238 5 {
10239 5 o_tile+=wpnsbuf[iwNPCs].tile;
10240
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10241 5 SIZEflags = d->SIZEflags;
10242
1/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if (SIZEflags != 0) init_size_flags();;
10243 5 }
10244
10245 75 bool eNPC::animate(int32_t index)
10246 {
10247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 if(switch_hooked) return enemy::animate(index);
10248
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 5 times.
75 if(dying)
10249 70 return Dead(index);
10250
10251
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(clk==0)
10252 {
10253 removearmos(x,y);
10254 }
10255
10256
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 switch(dmisc2)
10257 {
10258 case 0:
10259 {
10260 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10261 5 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10262
10263
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
10264 {
10265 dir=down;
10266 }
10267
10268
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
5 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
10269 {
10270 5 dir=right;
10271 5 }
10272 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/8)))
10273 {
10274 dir=up;
10275 }
10276 else
10277 {
10278 dir=left;
10279 }
10280 }
10281 5 break;
10282
10283 case 1:
10284 halting_walk(rate, homing, 0, hrate, 48);
10285
10286 if(clk2==1 && (misc < dmisc1) && !(zc_oldrand()&15))
10287 {
10288 newdir(rate, homing, 0);
10289 clk2=48;
10290 ++misc;
10291 }
10292
10293 if(clk2==0)
10294 misc=0;
10295
10296 break;
10297 }
10298
10299 5 return enemy::animate(index);
10300 75 }
10301
10302 75 void eNPC::draw(BITMAP *dest)
10303 {
10304 75 update_enemy_frame();
10305 75 enemy::draw(dest);
10306 75 }
10307
10308 int32_t eNPC::takehit(weapon*,weapon*)
10309 {
10310 return 0;
10311 }
10312
10313 94 eSpinTile::eSpinTile(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10314 94 {
10315
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
94 if(clk>0) // clk>0 when created by a Spinning Tile combo
10316 {
10317 94 o_tile=clk;
10318 94 cs=id>>12;
10319 94 }
10320
10321 94 id=id&0xFFF;
10322 94 clk=0;
10323
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 step=0;
10324 94 mainguy=false;
10325 94 SIZEflags = d->SIZEflags;
10326
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if (SIZEflags != 0) init_size_flags();;
10327 94 }
10328
10329 81 void eSpinTile::facehero()
10330 {
10331
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 80 times.
81 if(Hero.x-x==0)
10332 {
10333
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (Hero.y + 8 < y)
10334 1 dir = up;
10335 else
10336 dir = down;
10337 1 }
10338 else
10339 {
10340 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10341 80 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10342
10343
4/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 58 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 12 times.
80 if((ddir <= -5.0*PI/8.0) && (ddir > -7.0*PI/8.0))
10344 {
10345 12 dir=l_down;
10346 12 }
10347
4/4
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 1 times.
68 else if ((ddir <= -3.0*PI / 8.0) && (ddir > -5.0*PI / 8.0))
10348 {
10349 1 dir=down;
10350 1 }
10351
4/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 45 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 12 times.
67 else if ((ddir <= -1.0*PI / 8.0) && (ddir > -3.0*PI / 8.0))
10352 {
10353 12 dir=r_down;
10354 12 }
10355
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 6 times.
55 else if ((ddir <= 1.0*PI / 8.0) && (ddir > -1.0*PI / 8.0))
10356 {
10357 6 dir=right;
10358 6 }
10359
4/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 22 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 17 times.
49 else if ((ddir <= 3.0*PI / 8.0) && (ddir > 1.0*PI / 8.0))
10360 {
10361 17 dir=r_up;
10362 17 }
10363
4/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 8 times.
32 else if ((ddir <= 5.0*PI / 8.0) && (ddir > 3.0*PI / 8.0))
10364 {
10365 8 dir=up;
10366 8 }
10367
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 10 times.
24 else if ((ddir <= 7.0*PI / 8.0) && (ddir > 5.0*PI / 8.0))
10368 {
10369 6 dir=l_up;
10370 6 }
10371 else
10372 {
10373 18 dir=left;
10374 }
10375 }
10376 81 }
10377
10378
10379 15539 bool eSpinTile::animate(int32_t index)
10380 {
10381
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15539 times.
15539 if(switch_hooked) return enemy::animate(index);
10382
2/4
✓ Branch 0 taken 15539 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15539 times.
15539 if(fallclk||drownclk) return enemy::animate(index);
10383
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 14387 times.
15539 if(dying)
10384 {
10385 1152 return Dead(index);
10386 }
10387
10388
2/2
✓ Branch 0 taken 13146 times.
✓ Branch 1 taken 1241 times.
14387 if(clk==0)
10389 {
10390 1241 removearmos(x,y);
10391 1241 }
10392
10393 14387 ++misc;
10394
10395
2/2
✓ Branch 0 taken 14306 times.
✓ Branch 1 taken 81 times.
14387 if(misc==96)
10396 {
10397 81 facehero();
10398 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10399 81 double ddir=atan2_MSVC2022_FIX(double((Hero.y)-y),double(Hero.x-x));
10400 81 angular=true;
10401 81 angle=ddir;
10402 81 step=zslongToFix(dstep*100);
10403 81 }
10404
10405
8/8
✓ Branch 0 taken 14374 times.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 14359 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 14353 times.
✓ Branch 5 taken 6 times.
✓ Branch 6 taken 18 times.
✓ Branch 7 taken 14335 times.
14387 if(y>186 || y<=-16 || x>272 || x<=-16)
10406 52 kickbucket();
10407
10408 14387 sprite::move(step);
10409 14387 return enemy::animate(index);
10410 15539 }
10411
10412 15457 void eSpinTile::draw(BITMAP *dest)
10413 {
10414 15457 update_enemy_frame();
10415 15457 y-=(misc>>4);
10416 15457 yofs+=2;
10417 15457 enemy::draw(dest);
10418 15457 yofs-=2;
10419 15457 y+=(misc>>4);
10420 15457 }
10421
10422 15457 void eSpinTile::drawshadow(BITMAP *dest, bool translucent)
10423 {
10424 15457 flip = 0;
10425
1/2
✓ Branch 0 taken 15457 times.
✗ Branch 1 not taken.
15457 if(!can_drawshadow())
10426 15457 return;
10427 shadowtile = wpnsbuf[spr_shadow].tile+(clk%4);
10428 yofs+=4;
10429 enemy::drawshadow(dest, translucent);
10430 yofs-=4;
10431 15457 }
10432
10433 2874 eZora::eZora(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,0)
10434 2874 {
10435 //these are here to bypass compiler warnings about unused arguments
10436 2874 Clk=Clk;
10437 2874 mainguy=false;
10438
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2874 times.
2874 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10439
1/4
✓ Branch 0 taken 2874 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2874 if (SIZEflags != 0) init_size_flags();;
10440 2874 }
10441
10442 643945 void eZora::facehero()
10443 {
10444
2/2
✓ Branch 0 taken 10802 times.
✓ Branch 1 taken 633143 times.
643945 if(Hero.x-x==0)
10445 {
10446 10802 dir=(Hero.y+8<y)?up:down;
10447 10802 }
10448 else
10449 {
10450 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10451 633143 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10452
10453
4/4
✓ Branch 0 taken 128467 times.
✓ Branch 1 taken 504676 times.
✓ Branch 2 taken 48551 times.
✓ Branch 3 taken 79916 times.
633143 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
10454 {
10455 79916 dir=l_down;
10456 79916 }
10457
4/4
✓ Branch 0 taken 94203 times.
✓ Branch 1 taken 459024 times.
✓ Branch 2 taken 48551 times.
✓ Branch 3 taken 45652 times.
553227 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
10458 {
10459 45652 dir=down;
10460 45652 }
10461
4/4
✓ Branch 0 taken 123472 times.
✓ Branch 1 taken 384103 times.
✓ Branch 2 taken 48551 times.
✓ Branch 3 taken 74921 times.
507575 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
10462 {
10463 74921 dir=r_down;
10464 74921 }
10465
4/4
✓ Branch 0 taken 166271 times.
✓ Branch 1 taken 266383 times.
✓ Branch 2 taken 48551 times.
✓ Branch 3 taken 117720 times.
432654 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
10466 {
10467 117720 dir=right;
10468 117720 }
10469
4/4
✓ Branch 0 taken 130916 times.
✓ Branch 1 taken 184018 times.
✓ Branch 2 taken 48551 times.
✓ Branch 3 taken 82365 times.
314934 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
10470 {
10471 82365 dir=r_up;
10472 82365 }
10473
4/4
✓ Branch 0 taken 91723 times.
✓ Branch 1 taken 140846 times.
✓ Branch 2 taken 48551 times.
✓ Branch 3 taken 43172 times.
232569 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
10474 {
10475 43172 dir=up;
10476 43172 }
10477
4/4
✓ Branch 0 taken 126673 times.
✓ Branch 1 taken 62724 times.
✓ Branch 2 taken 78122 times.
✓ Branch 3 taken 48551 times.
189397 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
10478 {
10479 78122 dir=l_up;
10480 78122 }
10481 else
10482 {
10483 111275 dir=left;
10484 }
10485 }
10486 643945 }
10487
10488 872768 bool eZora::animate(int32_t index)
10489 {
10490
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 872768 times.
872768 if(switch_hooked) return enemy::animate(index);
10491
2/2
✓ Branch 0 taken 2954 times.
✓ Branch 1 taken 869814 times.
872768 if(dying)
10492 2954 return Dead(index);
10493
10494
2/2
✓ Branch 0 taken 863948 times.
✓ Branch 1 taken 5866 times.
869814 if(clk==0)
10495 {
10496 5866 removearmos(x,y);
10497 5866 }
10498
10499
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 869779 times.
869814 if(watch)
10500 {
10501 35 clock_zoras.push_back({screen_spawned, id});
10502 35 return true;
10503 }
10504
10505
2/2
✓ Branch 0 taken 225834 times.
✓ Branch 1 taken 643945 times.
869779 if(get_qr(qr_NEWENEMYTILES))
10506 {
10507 643945 facehero();
10508 643945 }
10509
10510
6/6
✓ Branch 0 taken 5341 times.
✓ Branch 1 taken 5092 times.
✓ Branch 2 taken 4266 times.
✓ Branch 3 taken 845474 times.
✓ Branch 4 taken 6586 times.
✓ Branch 5 taken 3020 times.
869779 switch(clk)
10511 {
10512 case 0: // reposition him
10513 {
10514 6586 int32_t t=0;
10515 6586 int32_t pos2=zc_oldrand()%160 + 16;
10516 6586 bool placed=false;
10517
10518
4/4
✓ Branch 0 taken 6514 times.
✓ Branch 1 taken 40421 times.
✓ Branch 2 taken 28041 times.
✓ Branch 3 taken 5866 times.
46935 while(!placed && t<160)
10519 {
10520 28041 rpos_t rpos = POS_TO_RPOS(pos2, screen_spawned);
10521 95711 auto [sx, sy] = COMBOXY_REGION(rpos);
10522 28041 mapscr* s = get_scr(screen_spawned);
10523
10524 84123 int32_t watertype = iswaterex_z3(s->data[pos2], -1, sx, sy, false, true, true, (bool)(editorflags & ENEMY_FLAG7));
10525
6/6
✓ Branch 0 taken 6720 times.
✓ Branch 1 taken 21321 times.
✓ Branch 2 taken 6709 times.
✓ Branch 3 taken 11 times.
✓ Branch 4 taken 403 times.
✓ Branch 5 taken 5794 times.
34238 if(watertype && ((editorflags & ENEMY_FLAG6) ||
10526
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 6677 times.
6709 ((combobuf[watertype].usrflags&cflag1) && (editorflags & ENEMY_FLAG5))
10527
3/4
✓ Branch 0 taken 6677 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6197 times.
✓ Branch 3 taken 6154 times.
6720 || (!(combobuf[watertype].usrflags&cflag1) && !(editorflags & ENEMY_FLAG5))) && (pos2&15)>0 && (pos2&15)<15)
10528 {
10529 5794 x=sx;
10530 5794 y=sy;
10531
2/2
✓ Branch 0 taken 340 times.
✓ Branch 1 taken 5454 times.
5794 if (!(editorflags & ENEMY_FLAG8)) hp=guysbuf[id&0xFFF].hp; // refill life each time, unless the flag is checked.
10532 5794 hxofs=1000; // avoid hit detection
10533 5794 stunclk=0;
10534 5794 placed=true;
10535 5794 }
10536
10537 40349 pos2+=19;
10538
10539
2/2
✓ Branch 0 taken 35573 times.
✓ Branch 1 taken 4776 times.
40349 if(pos2>=176)
10540 4776 pos2-=160;
10541
10542 40349 ++t;
10543 }
10544
10545
3/4
✓ Branch 0 taken 5794 times.
✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5794 times.
5866 if(!placed || whistleclk>=88) // can't place him, he's gone
10546 72 return true;
10547
10548 }
10549 5794 break;
10550
10551 case 35:
10552
2/2
✓ Branch 0 taken 3980 times.
✓ Branch 1 taken 1361 times.
5341 if(!get_qr(qr_NEWENEMYTILES))
10553 {
10554 1361 dir=(Hero.y+8<y)?up:down;
10555 1361 }
10556
10557 5341 hxofs=0;
10558 5341 break;
10559
10560 case 35+19:
10561 5092 addEwpn(x,y,z,wpn,2,wdp,dir,getUID(), 0, fakez);
10562 5092 sfx(wpnsfx(wpn),pan(x));
10563 5092 break;
10564
10565 case 35+66:
10566 4266 hxofs=1000;
10567 4266 break;
10568
10569 case 198:
10570 3020 clk=-1;
10571 3020 break;
10572 }
10573
10574 868987 return enemy::animate(index);
10575 872048 }
10576
10577 884024 void eZora::draw(BITMAP *dest)
10578 {
10579
2/2
✓ Branch 0 taken 20355 times.
✓ Branch 1 taken 863669 times.
884024 if (isSubmerged())
10580 20355 return;
10581
10582 863669 update_enemy_frame();
10583 863669 enemy::draw(dest);
10584 884024 }
10585
10586 884256 bool eZora::isSubmerged() const
10587 {
10588 884256 return clk < 3;
10589 }
10590
10591
3/6
✓ Branch 0 taken 52553 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 52553 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 52553 times.
✗ Branch 5 not taken.
105106 eStalfos::eStalfos(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10592 52553 {
10593 52553 multishot= timer = fired = dashing = 0;
10594 52553 hashero = false;
10595 52553 dummy_bool[0]=false;
10596
4/8
✓ Branch 0 taken 52553 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 52553 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 52553 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 52553 times.
✗ Branch 7 not taken.
52553 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
10597
5/6
✓ Branch 0 taken 1004 times.
✓ Branch 1 taken 51549 times.
✓ Branch 2 taken 1004 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 520 times.
✓ Branch 5 taken 484 times.
52553 if(dmisc9==e9tARMOS && zc_oldrand()&1)
10598 {
10599
2/4
✓ Branch 0 taken 520 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 520 times.
✗ Branch 3 not taken.
520 step=zslongToFix(dmisc10*100);
10600
10601
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 502 times.
520 if(anim==aARMOS4) o_tile+=20;
10602 520 }
10603
10604
3/4
✓ Branch 0 taken 52553 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1004 times.
✓ Branch 3 taken 51549 times.
52553 if(flags & guy_fade_flicker)
10605 {
10606 1004 clk=0;
10607 1004 superman = 1;
10608 1004 fading=fade_flicker;
10609
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1004 times.
1004 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10610 1004 dir=down;
10611
10612
4/6
✓ Branch 0 taken 1004 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1004 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 443 times.
✓ Branch 5 taken 561 times.
1004 if(!canmove(down,(zfix)8,spw_none,false))
10613
3/6
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 443 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 443 times.
✗ Branch 5 not taken.
443 clk3=int32_t(13.0/step);
10614 1004 }
10615
3/4
✓ Branch 0 taken 51549 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 51416 times.
✓ Branch 3 taken 133 times.
51549 else if(flags & guy_fade_instant)
10616 {
10617 133 clk=0;
10618 133 }
10619
10620
1/2
✓ Branch 0 taken 52553 times.
✗ Branch 1 not taken.
52553 shadowdistance = 0;
10621 52553 clk4 = clk5 = 0;
10622 //nets+2380;
10623
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 52551 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
52553 if (SIZEflags != 0) init_size_flags();;
10624 52553 }
10625
10626 16383593 bool eStalfos::animate(int32_t index)
10627 {
10628
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 16383337 times.
16383593 if(switch_hooked) return enemy::animate(index);
10629
4/4
✓ Branch 0 taken 16382414 times.
✓ Branch 1 taken 923 times.
✓ Branch 2 taken 1344 times.
✓ Branch 3 taken 16381070 times.
16383337 if(fallclk||drownclk)
10630 {
10631 2267 return enemy::animate(index);
10632 }
10633
2/2
✓ Branch 0 taken 369776 times.
✓ Branch 1 taken 16011294 times.
16381070 if(dying)
10634 {
10635
2/2
✓ Branch 0 taken 369725 times.
✓ Branch 1 taken 51 times.
369776 if(hashero)
10636 {
10637 51 Hero.setEaten(0);
10638 51 hashero=false;
10639 51 }
10640
10641
10/14
✓ Branch 0 taken 38171 times.
✓ Branch 1 taken 331605 times.
✓ Branch 2 taken 3685 times.
✓ Branch 3 taken 34486 times.
✓ Branch 4 taken 187 times.
✓ Branch 5 taken 3498 times.
✓ Branch 6 taken 187 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 187 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 187 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 187 times.
369776 if(dmisc9==e9tROPE && dmisc2==e2tBOMBCHU && !fired && (hp<=0 && !immortal) && hp>-1000 && wpn>wEnemyWeapons)
10642 {
10643 187 hp=-1000;
10644
5/10
✓ Branch 0 taken 187 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 187 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 187 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 187 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 187 times.
✗ Branch 9 not taken.
187 weapon *ew=new weapon(x,y,z, wpn, 0, dmisc4, dir,-1,getUID(),false);
10645 187 Ewpns.add(ew);
10646 187 ew->fakez = fakez;
10647
10648
3/4
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 68 times.
✓ Branch 2 taken 119 times.
✗ Branch 3 not taken.
187 if(wpn==ewSBomb || wpn==ewBomb)
10649 {
10650 187 ew->step=0;
10651 187 ew->id=wpn;
10652 187 ew->misc=50;
10653 187 ew->clk=48;
10654 187 }
10655
10656 187 fired=true;
10657 187 }
10658
6/6
✓ Branch 0 taken 163945 times.
✓ Branch 1 taken 205644 times.
✓ Branch 2 taken 137553 times.
✓ Branch 3 taken 26392 times.
✓ Branch 4 taken 137535 times.
✓ Branch 5 taken 18 times.
369589 else if(wpn && wpn!=ewBrang && dmisc2==e2tFIREOCTO) // Fire Octo
10659 {
10660
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 1 times.
18 if(!dummy_bool[0])
10661 {
10662 1 int32_t wpn2 = wpn+dmisc3;
10663
10664
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(wpn2 <= wEnemyWeapons || wpn2 >= wMax)
10665 {
10666 wpn2=wpn;
10667 }
10668
10669 1 dummy_bool[0]=true;
10670 1 addEwpn(x,y,z,wpn2,0,dmisc4,up, getUID(), 0, fakez);
10671 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10672 1 addEwpn(x,y,z,wpn2,0,dmisc4,down, getUID(), 0, fakez);
10673 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10674 1 addEwpn(x,y,z,wpn2,0,dmisc4,left, getUID(), 0, fakez);
10675 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10676 1 addEwpn(x,y,z,wpn2,0,dmisc4,right, getUID(), 0, fakez);
10677 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10678 1 addEwpn(x,y,z,wpn2,0,dmisc4,l_up, getUID(), 0, fakez);
10679 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10680 1 addEwpn(x,y,z,wpn2,0,dmisc4,r_up, getUID(), 0, fakez);
10681 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10682 1 addEwpn(x,y,z,wpn2,0,dmisc4,l_down, getUID(), 0, fakez);
10683 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10684 1 addEwpn(x,y,z,wpn2,0,dmisc4,r_down, getUID(), 0, fakez);
10685 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10686 1 sfx(wpnsfx(wpn2),pan(x));
10687 1 }
10688 18 }
10689
10690 369776 KillWeapon();
10691 369776 return Dead(index);
10692 }
10693 //vire split
10694 //2.10 checked !fslide(), but nothing uses that now anyway. -Z
10695 //Perhaps the problem occurs when vires die because they have < 0 HP, in this check?
10696
13/14
✓ Branch 0 taken 22021 times.
✓ Branch 1 taken 15989273 times.
✓ Branch 2 taken 22021 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 390 times.
✓ Branch 5 taken 21631 times.
✓ Branch 6 taken 1192696 times.
✓ Branch 7 taken 14818208 times.
✓ Branch 8 taken 1191149 times.
✓ Branch 9 taken 1547 times.
✓ Branch 10 taken 6686 times.
✓ Branch 11 taken 1184463 times.
✓ Branch 12 taken 1326 times.
✓ Branch 13 taken 5360 times.
16011294 else if(((hp<=0 && !immortal) && dmisc2==e2tSPLIT) || (dmisc2==e2tSPLITHIT && hp>0 && hp<guysbuf[id&0xFFF].hp && !slide() && (sclk&255)<=1)) //Split into enemies
10697 {
10698 1716 stop_bgsfx(index);
10699 1716 int32_t kids = guys.Count();
10700 1716 int32_t id2=dmisc3;
10701
2/2
✓ Branch 0 taken 3385 times.
✓ Branch 1 taken 1716 times.
5101 for(int32_t i=0; i < dmisc4; i++)
10702 {
10703
4/6
✓ Branch 0 taken 1272 times.
✓ Branch 1 taken 2113 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2113 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3385 times.
3385 if(addenemy(screen_spawned,x,y,id2+(guysbuf[id2].type==eeKEESE ? 0 : ((editorflags & ENEMY_FLAG5) ? 0 : (i<<12))),-21-(i%4)))
10704 3385 ((enemy*)guys.spr(kids+i))->count_enemy = false;
10705 3385 }
10706
10707
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1715 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1716 if (itemguy && guys.Count()) // Hand down the carried item
10708 {
10709 1 int guycarryingitem = guys.Count()-1;
10710 1 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
10711 1 itemguy = false;
10712 1 }
10713
10714
2/2
✓ Branch 0 taken 1699 times.
✓ Branch 1 taken 17 times.
1716 if(hashero)
10715 {
10716 17 Hero.setEaten(0);
10717 17 hashero=false;
10718 17 }
10719
10720
4/4
✓ Branch 0 taken 1688 times.
✓ Branch 1 taken 28 times.
✓ Branch 2 taken 1326 times.
✓ Branch 3 taken 362 times.
1716 if(deadsfx > 0 && dmisc2==e2tSPLIT)
10721 362 sfx(deadsfx,pan(x));
10722
10723 1716 return true;
10724 }
10725
10726
2/2
✓ Branch 0 taken 71283 times.
✓ Branch 1 taken 15938295 times.
16009578 if(fading)
10727 {
10728
2/2
✓ Branch 0 taken 1230 times.
✓ Branch 1 taken 70053 times.
71283 if(++clk4 > 60)
10729 {
10730 1230 clk4=0;
10731 1230 superman=0;
10732 1230 fading=0;
10733
10734
4/6
✓ Branch 0 taken 969 times.
✓ Branch 1 taken 261 times.
✓ Branch 2 taken 969 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 969 times.
1230 if(flags&guy_armos && z==0 && fakez == 0)
10735 {
10736 //if a custom size (not 16px by 16px)
10737
10738 //if a custom size (not 16px by 16px)
10739
3/4
✓ Branch 0 taken 178 times.
✓ Branch 1 taken 791 times.
✓ Branch 2 taken 178 times.
✗ Branch 3 not taken.
969 if (activated_handle && !activated_handle->is_rpos())
10740 removearmos(x,y);
10741 else
10742 {
10743
4/8
✓ Branch 0 taken 969 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 969 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 969 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 969 times.
969 if (txsz > 1 || tysz > 1 || (SIZEflags&OVERRIDE_HIT_WIDTH) || (SIZEflags&OVERRIDE_HIT_HEIGHT) )//remove more than one combo based on enemy size
10744 {
10745 //if removing a block, then adjust y by -1 as the enemy spawns at y+1
10746 for(int32_t dx = 0; dx < tysz; dx ++)
10747 {
10748 for(int32_t dy = 0; dy < tysz; dy++)
10749 {
10750 removearmos((int32_t)x+(dx*16),(int32_t)y+(dy*16)+1);
10751 did_armos = false;
10752 }
10753 removearmos((int32_t)x+(dx*16), (int32_t)y+((tysz-1)*16)+1);
10754 did_armos = false;
10755 }
10756 for(int32_t dy = 0; dy < tysz; dy ++)
10757 {
10758 removearmos((int32_t)x+((txsz-1)*16), (int32_t)y+(dy*16)+1);
10759 did_armos = false;
10760 }
10761 removearmos((int32_t)x+((txsz-1)*16), (int32_t)y+((tysz-1)*16)+1);
10762 }
10763 969 else removearmos(x,y);
10764 }
10765
10766 969 }
10767
10768 1230 clk2=0;
10769
10770 1230 newdir();
10771 1230 }
10772 70053 else return enemy::animate(index);
10773 1230 }
10774
6/8
✓ Branch 0 taken 148631 times.
✓ Branch 1 taken 15789664 times.
✓ Branch 2 taken 148631 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 148631 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 139061 times.
✓ Branch 7 taken 9570 times.
15938295 else if(flags&guy_armos && z==0 && fakez == 0 && clk==0)
10775 9570 removearmos(x,y);
10776
10777
10778
2/2
✓ Branch 0 taken 7873 times.
✓ Branch 1 taken 15931652 times.
15939525 if(hashero)
10779 {
10780 7873 Hero.setX(x);
10781 7873 Hero.setY(y);
10782 7873 ++clk2;
10783
10784
4/4
✓ Branch 0 taken 6360 times.
✓ Branch 1 taken 1513 times.
✓ Branch 2 taken 6784 times.
✓ Branch 3 taken 1089 times.
7873 if(clk2==(dmisc8==0 ? 95 : dmisc8))
10785 {
10786
3/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 1058 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
1089 switch(dmisc7)
10787 {
10788 case e7tEATITEMS:
10789 {
10790
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 22 times.
5654 for(int32_t i=0; i<MAXITEMS; i++)
10791 {
10792
2/2
✓ Branch 0 taken 5610 times.
✓ Branch 1 taken 22 times.
5632 if(itemsbuf[i].flags&item_edible)
10793 22 game->set_item(i, false);
10794 5632 }
10795
10796 22 break;
10797 }
10798
10799 case e7tEATMAGIC:
10800 9 game->change_dmagic(-1*game->get_magicdrainrate());
10801 9 break;
10802
10803 case e7tEATRUPEES:
10804 game->change_drupy(-1);
10805 break;
10806 }
10807
10808 1089 clk2=0;
10809 1089 }
10810
10811
2/2
✓ Branch 0 taken 561 times.
✓ Branch 1 taken 7312 times.
7873 if((clk&0x18)==8) // stop its animation on the middle frame
10812 7312 --clk;
10813 7873 }
10814
4/4
✓ Branch 0 taken 1056599 times.
✓ Branch 1 taken 14875053 times.
✓ Branch 2 taken 620077 times.
✓ Branch 3 taken 436522 times.
15931652 else if(!(wpn==ewBrang && WeaponOut())) //WeaponOut uses misc
10815 {
10816 // Movement engine
10817
6/6
✓ Branch 0 taken 844908 times.
✓ Branch 1 taken 14650222 times.
✓ Branch 2 taken 3399 times.
✓ Branch 3 taken 108 times.
✓ Branch 4 taken 14646656 times.
✓ Branch 5 taken 59 times.
15495130 if(clk>=0) switch(id>>12)
10818 {
10819 case 0: // Normal movement
10820
10821 /*
10822 if((dmisc9==e9tLEEVER || dmisc9==e9tZ3LEEVER) && !slide()) //Leever
10823 {
10824 // Overloading clk4 (Tribble clock) here...
10825 step=17/100.0;
10826 if(clk4<32) misc=1;
10827 else if(clk4<48) misc=2;
10828 else if(clk4<300) { misc=3; step = dstep/100.0; }
10829 else if(clk4<316) misc=2;
10830 else if(clk4<412) misc=1;
10831 else if(clk4<540) { misc=0; step=0; }
10832 else clk4=0;
10833 if(clk4==48) clk=0;
10834 hxofs=(misc>=2)?0:1000;
10835 if (dmisc9==e9tLEEVER)
10836 variable_walk(rate, homing, 0);
10837 else
10838 variable_walk_8(rate, homing, 4, 0);
10839 break;
10840 }
10841 */
10842
4/4
✓ Branch 0 taken 14267622 times.
✓ Branch 1 taken 379034 times.
✓ Branch 2 taken 417076 times.
✓ Branch 3 taken 13850546 times.
14646656 if(dmisc9==e9tVIRE || dmisc9==e9tPOLSVOICE) //Vire
10843 {
10844 796110 vire_hop();
10845 796110 break;
10846 }
10847
2/2
✓ Branch 0 taken 1061272 times.
✓ Branch 1 taken 12789274 times.
13850546 else if(dmisc9==e9tROPE) //Rope charge
10848 {
10849
9/10
✓ Branch 0 taken 1043850 times.
✓ Branch 1 taken 17422 times.
✓ Branch 2 taken 153470 times.
✓ Branch 3 taken 890380 times.
✓ Branch 4 taken 141385 times.
✓ Branch 5 taken 12085 times.
✓ Branch 6 taken 140560 times.
✓ Branch 7 taken 825 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 140560 times.
1061272 if(!fired && dashing && !stunclk && !watch && !frozenclock)
10850 {
10851
5/6
✓ Branch 0 taken 9076 times.
✓ Branch 1 taken 131484 times.
✓ Branch 2 taken 47 times.
✓ Branch 3 taken 9029 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 47 times.
140560 if(dmisc2==e2tBOMBCHU && HeroInRange(16) && wpn+dmisc3 > wEnemyWeapons) //Bombchu
10852 {
10853
10854
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 33 times.
47 if ( get_qr(qr_BOMBCHUSUPERBOMB) )
10855 {
10856 14 hp=-1000;
10857
10858
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
14 if(wpn+dmisc3 > wEnemyWeapons && wpn+dmisc3 < wMax)
10859 {
10860
5/10
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 14 times.
✗ Branch 9 not taken.
14 weapon *ew=new weapon(x,y,z, wpn+dmisc3, 0, dmisc4, dir,-1,getUID());
10861 14 Ewpns.add(ew);
10862 14 ew->fakez = fakez;
10863
10864
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
14 if(wpn==ewSBomb || wpn==ewBomb)
10865 {
10866 14 ew->step=0;
10867 14 ew->id=wpn+dmisc3;
10868 14 ew->misc=50;
10869 14 ew->clk=48;
10870 14 }
10871
10872 14 fired=true;
10873 14 }
10874 else
10875 {
10876 weapon *ew=new weapon(x,y,z, wpn, 0, dmisc4, dir,-1,getUID());
10877 Ewpns.add(ew);
10878 ew->fakez = fakez;
10879
10880 if(wpn==ewSBomb || wpn==ewBomb)
10881 {
10882 ew->step=0;
10883 ew->id=wpn;
10884 ew->misc=50;
10885 ew->clk=48;
10886 }
10887
10888 fired=true;
10889 }
10890 14 }
10891
10892 else
10893 {
10894 33 hp=-1000;
10895
10896 int32_t wpn2;
10897
2/4
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 33 times.
33 if(wpn+dmisc3 > wEnemyWeapons && wpn+dmisc3 < wMax)
10898 33 wpn2=wpn;
10899 else
10900 wpn2=wpn;
10901
10902
5/10
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 33 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 33 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 33 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 33 times.
✗ Branch 9 not taken.
33 weapon *ew=new weapon(x,y,z, wpn2, 0, dmisc4, dir,-1,getUID());
10903 33 Ewpns.add(ew);
10904 33 ew->fakez = fakez;
10905
10906
3/4
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
33 if(wpn2==ewSBomb || wpn2==ewBomb)
10907 {
10908 33 ew->step=0;
10909 33 ew->id=wpn2;
10910 33 ew->misc=50;
10911 33 ew->clk=48;
10912 33 }
10913
10914 33 fired=true;
10915 }
10916 47 }
10917 140560 }
10918
10919 1061272 charge_attack();
10920 1061272 break;
10921 }
10922 /*
10923 * Boomerang-throwers have a halt count of 1
10924 * Zols have a halt count of (zc_oldrand()&7)<<4
10925 * Gels have a halt count of ((zc_oldrand()&7)<<3)+2
10926 * Everything else has 48
10927 */
10928 else
10929 {
10930
2/2
✓ Branch 0 taken 572383 times.
✓ Branch 1 taken 12216891 times.
12789274 if(wpn==ewBrang) // Goriya
10931 {
10932 572383 halting_walk(rate,homing,0,hrate, 1);
10933 572383 }
10934
4/4
✓ Branch 0 taken 12067291 times.
✓ Branch 1 taken 149600 times.
✓ Branch 2 taken 4783350 times.
✓ Branch 3 taken 7283941 times.
12216891 else if(dmisc9==e9tNORMAL && wpn==0)
10935 {
10936
2/2
✓ Branch 0 taken 717973 times.
✓ Branch 1 taken 6565968 times.
7283941 if(dmisc2==e2tSPLITHIT) // Zol
10937 {
10938 717973 halting_walk(rate,homing,0,hrate,(zc_oldrand()&7)<<4);
10939 717973 }
10940
4/4
✓ Branch 0 taken 1773827 times.
✓ Branch 1 taken 4792141 times.
✓ Branch 2 taken 1557936 times.
✓ Branch 3 taken 215891 times.
6565968 else if(frate<=8 && starting_hp==1) // Gel
10941 {
10942 215891 halting_walk(rate,homing,0,hrate,((zc_oldrand()&7)<<3)+2);
10943 215891 }
10944 else // Other
10945 {
10946 6350077 halting_walk(rate,homing,0,hrate, 48);
10947 }
10948 7283941 }
10949 else // Other
10950 {
10951 4932950 halting_walk(rate,homing,0,hrate, 48);
10952 }
10953 }
10954
10955 //if not in midair, and Hero's swinging sword is nearby, jump.
10956 /*if (dmisc9==e9tZ3STALFOS && z==0 && (!(isSideViewGravity()) || !_walkflag(x,y+16,0))
10957 && Hero.getAttackClk()==5 && Hero.getAttack()==wSword && distance(x,y,Hero.getX(),Hero.getY())<32)
10958 {
10959 facehero(false);
10960 sclk=16+((dir^1)<<8);
10961 fall=-FEATHERJUMP;
10962 sfx(WAV_ZN1JUMP,pan(x));
10963 }*/
10964 12789274 break;
10965
10966 // Following cases are for just after creation-by-splitting.
10967 case 1:
10968
2/2
✓ Branch 0 taken 2555 times.
✓ Branch 1 taken 844 times.
3399 if(misc==1)
10969 {
10970 844 dir=up;
10971 844 step=8;
10972 844 }
10973
10974
2/2
✓ Branch 0 taken 811 times.
✓ Branch 1 taken 2588 times.
3399 if(misc<=2)
10975 {
10976 2588 move(step);
10977
10978
2/2
✓ Branch 0 taken 2049 times.
✓ Branch 1 taken 539 times.
2588 if(!canmove(dir,(zfix)0,0,false))
10979 539 dir=down;
10980 2588 }
10981
10982
2/2
✓ Branch 0 taken 2588 times.
✓ Branch 1 taken 811 times.
3399 if(misc==3)
10983 {
10984
2/2
✓ Branch 0 taken 294 times.
✓ Branch 1 taken 517 times.
811 if(canmove(right,(zfix)16,0,false))
10985 517 x+=16;
10986 811 }
10987
10988 3399 ++misc;
10989 3399 break;
10990
10991 case 2:
10992
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 15 times.
59 if(misc==1)
10993 {
10994 15 dir=down;
10995 15 step=8;
10996 15 }
10997
10998
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 45 times.
59 if(misc<=2)
10999 {
11000 45 move(step);
11001 /*
11002 if(!canmove(dir,(zfix)0,0,false))
11003 dir=up;
11004 */
11005 45 }
11006
11007
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 14 times.
59 if(misc==3)
11008 {
11009
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(canmove(left,(zfix)16,0,false))
11010 14 x-=16;
11011 14 }
11012
11013 59 ++misc;
11014 59 break;
11015
11016 default:
11017
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 28 times.
108 if(misc==1)
11018 {
11019 28 dir=(zc_oldrand()%4);
11020 28 step=8;
11021 28 }
11022
11023
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 83 times.
108 if(misc<=2)
11024 {
11025 83 move(step);
11026
11027
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 2 times.
83 if(!canmove(dir,(zfix)0,0,false))
11028 2 dir=dir^1;
11029 83 }
11030
11031
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 25 times.
108 if(misc==3)
11032 {
11033
3/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
25 if(dir >= left && canmove(dir,(zfix)16,0,false))
11034 8 x+=(dir==left ? -16 : 16);
11035 25 }
11036
11037 108 ++misc;
11038 108 break;
11039 14650222 }
11040
11041
4/4
✓ Branch 0 taken 25806 times.
✓ Branch 1 taken 15469324 times.
✓ Branch 2 taken 24956 times.
✓ Branch 3 taken 850 times.
15495130 if(id>>12 && misc>=4) //recently spawned by a split enemy
11042 {
11043 850 id&=0xFFF;
11044 850 step = zslongToFix(dstep*100);
11045
11046
2/2
✓ Branch 0 taken 849 times.
✓ Branch 1 taken 1 times.
850 if(x<32) x=32;
11047
11048
2/2
✓ Branch 0 taken 826 times.
✓ Branch 1 taken 24 times.
850 if(x>world_w-48) x=world_w-48;
11049
11050
2/2
✓ Branch 0 taken 824 times.
✓ Branch 1 taken 26 times.
850 if(y<32) y=32;
11051
11052
2/2
✓ Branch 0 taken 843 times.
✓ Branch 1 taken 7 times.
850 if(y>world_h-48) y=world_h-48;
11053
11054 850 misc=3;
11055 850 }
11056 15495130 }
11057 else
11058 {
11059 //sfx(wpnsfx(wpn),pan(x));
11060
1/2
✓ Branch 0 taken 436522 times.
✗ Branch 1 not taken.
436522 if(clk2>2) clk2--;
11061 }
11062
11063 // Fire Zol
11064
8/8
✓ Branch 0 taken 6346424 times.
✓ Branch 1 taken 9593101 times.
✓ Branch 2 taken 174420 times.
✓ Branch 3 taken 6172004 times.
✓ Branch 4 taken 1375 times.
✓ Branch 5 taken 173045 times.
✓ Branch 6 taken 1334 times.
✓ Branch 7 taken 41 times.
15939525 if(wpn && dmisc1==e1tEACHTILE && clk2==1 && !hclk)
11065 {
11066 1334 addEwpn(x,y,z,wpn,0,wdp,dir, getUID(), 0, fakez);
11067 1334 sfx(wpnsfx(wpn),pan(x));
11068
11069 1334 int32_t i=Ewpns.Count()-1;
11070 1334 weapon *ew = (weapon*)(Ewpns.spr(i));
11071
11072
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1334 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1334 if(wpn==ewFIRETRAIL && wpnsbuf[ewFIRETRAIL].frames>1)
11073 {
11074 ew->aframe=zc_oldrand()%wpnsbuf[ewFIRETRAIL].frames;
11075 if ( ew->do_animation ) ew->tile+=ew->aframe;
11076 }
11077 1334 }
11078 // Goriya
11079
14/16
✓ Branch 0 taken 1056599 times.
✓ Branch 1 taken 14881592 times.
✓ Branch 2 taken 472320 times.
✓ Branch 3 taken 584279 times.
✓ Branch 4 taken 459560 times.
✓ Branch 5 taken 12760 times.
✓ Branch 6 taken 426583 times.
✓ Branch 7 taken 32977 times.
✓ Branch 8 taken 426583 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 423842 times.
✓ Branch 11 taken 2741 times.
✓ Branch 12 taken 423842 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 417426 times.
✓ Branch 15 taken 6416 times.
15938191 else if(wpn==ewBrang && clk2==1 && sclk==0 && !stunclk && !frozenclock && !watch && wpn && !WeaponOut())
11080 {
11081 6416 misc=index+100;
11082
7/14
✓ Branch 0 taken 6416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6416 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6416 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6416 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 6416 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6416 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 6416 times.
✗ Branch 13 not taken.
6416 Ewpns.add(new weapon(x,y-fakez,z,wpn,misc,wdp,dir, -1,getUID(),false));
11083 6416 ((weapon*)Ewpns.spr(Ewpns.Count()-1))->dummy_bool[0]=false;
11084
11085
2/2
✓ Branch 0 taken 6159 times.
✓ Branch 1 taken 257 times.
6416 if(dmisc1==2)
11086 {
11087 257 int32_t ndir=dir;
11088
11089
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 251 times.
257 if(Hero.x-x==0)
11090 {
11091 6 ndir=(Hero.y+8<y)?up:down;
11092 6 }
11093 else //turn to face Hero
11094 {
11095 double _MSVC2022_tmp1, _MSVC2022_tmp2;
11096 251 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
11097
11098
4/4
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 193 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 13 times.
251 if((ddir<=(((-2)*PI)/8))&&(ddir>(((-6)*PI)/8)))
11099 {
11100 13 ndir=down;
11101 13 }
11102
4/4
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 125 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 68 times.
238 else if((ddir<=(((2)*PI)/8))&&(ddir>(((-2)*PI)/8)))
11103 {
11104 68 ndir=right;
11105 68 }
11106
4/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 48 times.
170 else if((ddir<=(((6)*PI)/8))&&(ddir>(((2)*PI)/8)))
11107 {
11108 48 ndir=up;
11109 48 }
11110 else
11111 {
11112 122 ndir=left;
11113 }
11114 }
11115
11116 257 ((weapon*)Ewpns.spr(Ewpns.Count()-1))->dummy_bool[0]=true;
11117
11118
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 223 times.
257 if(canmove(ndir,false))
11119 {
11120 223 dir=ndir;
11121 223 }
11122 257 }
11123 6416 }
11124
15/16
✓ Branch 0 taken 15870915 times.
✓ Branch 1 taken 60860 times.
✓ Branch 2 taken 223166 times.
✓ Branch 3 taken 15708609 times.
✓ Branch 4 taken 196679 times.
✓ Branch 5 taken 26487 times.
✓ Branch 6 taken 171787 times.
✓ Branch 7 taken 24892 times.
✓ Branch 8 taken 170382 times.
✓ Branch 9 taken 1405 times.
✓ Branch 10 taken 155282 times.
✓ Branch 11 taken 15100 times.
✓ Branch 12 taken 155282 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 944 times.
✓ Branch 15 taken 154338 times.
15931775 else if((clk2==16 || dmisc1==e1tCONSTANT) && dmisc1!=e1tEACHTILE && wpn && wpn!=ewBrang && sclk==0 && !stunclk && !frozenclock && !watch)
11125
3/3
✓ Branch 0 taken 27446 times.
✓ Branch 1 taken 125986 times.
✓ Branch 2 taken 906 times.
154338 switch(dmisc1)
11126 {
11127 case e1tCONSTANT: //Deathnut
11128 {
11129 // Overloading clk5 (Like Like clock) to avoid making another clock just for this attack...
11130
2/2
✓ Branch 0 taken 123398 times.
✓ Branch 1 taken 2588 times.
125986 if(clk5>64)
11131 {
11132 2588 clk5=0;
11133 2588 fired=false;
11134 2588 }
11135
11136 125986 clk5+=(zc_oldrand()&3);
11137
11138
4/4
✓ Branch 0 taken 76865 times.
✓ Branch 1 taken 49121 times.
✓ Branch 2 taken 25698 times.
✓ Branch 3 taken 51167 times.
125986 if((clk5>24)&&(clk5<52))
11139 {
11140
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51167 times.
51167 if ( do_animation )tile+=20; //firing
11141
11142
4/4
✓ Branch 0 taken 28011 times.
✓ Branch 1 taken 23156 times.
✓ Branch 2 taken 25178 times.
✓ Branch 3 taken 2833 times.
51167 if(!fired&&(clk5>=38))
11143 {
11144
5/10
✓ Branch 0 taken 2833 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2833 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2833 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2833 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2833 times.
✗ Branch 9 not taken.
2833 Ewpns.add(new weapon(x,y,z, wpn, 0, wdp, dir, -1,getUID(),false));
11145 2833 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
11146 2833 sfx(wpnsfx(wpn),pan(x));
11147 2833 fired=true;
11148 2833 }
11149 51167 }
11150
11151 125986 break;
11152 }
11153
11154 case e1tFIREOCTO: //Fire Octo
11155 906 timer=zc_oldrand()%50+50;
11156 906 break;
11157
11158 default:
11159 27446 FireWeapon();
11160 27446 break;
11161 154338 }
11162
11163 /* Fire again if:
11164 * - clk2 about to run out
11165 * - not already double-firing (dmisc1 is 1)
11166 * - not carrying Hero
11167 * - one in 0xF chance
11168 */
11169
8/10
✓ Branch 0 taken 530545 times.
✓ Branch 1 taken 15408980 times.
✓ Branch 2 taken 4567 times.
✓ Branch 3 taken 525978 times.
✓ Branch 4 taken 4567 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4567 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 4277 times.
✓ Branch 9 taken 290 times.
15939525 if(clk2==1 && (multishot < dmisc6) && dmisc1 != e1tEACHTILE && !hashero && !(zc_oldrand()&15))
11170 {
11171 #if 1
11172 290 newdir(rate, homing, grumble);
11173 #else
11174 dir^=2;
11175 #endif
11176 290 clk2=28;
11177 290 ++multishot;
11178 290 }
11179
11180
2/2
✓ Branch 0 taken 3594397 times.
✓ Branch 1 taken 12345128 times.
15939525 if(clk2==0)
11181 {
11182 12345128 multishot = 0;
11183 12345128 }
11184
11185
2/2
✓ Branch 0 taken 15875215 times.
✓ Branch 1 taken 64310 times.
15939525 if(timer) //Fire Octo
11186 {
11187 64310 clk2=15; //this keeps the octo in place until he's done firing
11188
11189
2/2
✓ Branch 0 taken 48558 times.
✓ Branch 1 taken 15752 times.
64310 if(!(timer%4))
11190 {
11191 15752 FireBreath(false);
11192 15752 }
11193
11194 64310 --timer;
11195 64310 }
11196
11197
2/2
✓ Branch 0 taken 15690132 times.
✓ Branch 1 taken 249393 times.
15939525 if(dmisc2==e2tTRIBBLE)
11198 249393 ++clk4;
11199
11200
7/10
✓ Branch 0 taken 4480 times.
✓ Branch 1 taken 15935045 times.
✓ Branch 2 taken 693 times.
✓ Branch 3 taken 15938832 times.
✓ Branch 4 taken 693 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 693 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 693 times.
15939525 if(clk4==(dmisc5 ? dmisc5 : 256) && (dmisc2==e2tTRIBBLE) && dmisc3 && dmisc4)
11201 {
11202 693 int32_t kids = guys.Count();
11203 693 int32_t id2=dmisc3;
11204
11205
2/2
✓ Branch 0 taken 693 times.
✓ Branch 1 taken 693 times.
1386 for(int32_t i=0; i<dmisc4; i++)
11206 {
11207
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 693 times.
693 if(addenemy(screen_spawned,x,y,id2,-24))
11208 {
11209
1/2
✓ Branch 0 taken 693 times.
✗ Branch 1 not taken.
693 if(itemguy) // Hand down the carried item
11210 {
11211 int guycarryingitem = guys.Count()-1;
11212 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
11213 itemguy = false;
11214 }
11215
11216 693 ((enemy*)guys.spr(kids+i))->count_enemy = false;
11217 693 }
11218 693 }
11219
11220
1/2
✓ Branch 0 taken 693 times.
✗ Branch 1 not taken.
693 if(hashero)
11221 {
11222 Hero.setEaten(0);
11223 hashero=false;
11224 }
11225
11226 693 stop_bgsfx(index);
11227 693 return true;
11228 }
11229
11230 15938832 return enemy::animate(index);
11231 16383593 }
11232
11233 16837213 void eStalfos::draw(BITMAP *dest)
11234 {
11235 16837213 update_enemy_frame();
11236
11237
8/8
✓ Branch 0 taken 16836290 times.
✓ Branch 1 taken 923 times.
✓ Branch 2 taken 16834946 times.
✓ Branch 3 taken 1344 times.
✓ Branch 4 taken 87435 times.
✓ Branch 5 taken 16747511 times.
✓ Branch 6 taken 76320 times.
✓ Branch 7 taken 11115 times.
16837213 if(!fallclk&&!drownclk&&(dmisc2==e2tBOMBCHU)&&dashing)
11238 {
11239
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11115 times.
11115 if ( do_animation )tile+=20;
11240 11115 }
11241
11242 16837213 enemy::draw(dest);
11243 16837213 }
11244
11245 8111423 bool eStalfos::can_drawshadow() const
11246 {
11247 8111423 return enemy::can_drawshadow();
11248 }
11249 8111423 void eStalfos::drawshadow(BITMAP *dest, bool translucent)
11250 {
11251 8111423 int32_t tempy=yofs;
11252
11253
4/4
✓ Branch 0 taken 7896005 times.
✓ Branch 1 taken 215418 times.
✓ Branch 2 taken 7799804 times.
✓ Branch 3 taken 311619 times.
8111423 if((dmisc9 == e9tPOLSVOICE || dmisc9==e9tVIRE) && !get_qr(qr_ENEMIESZAXIS))
11254 {
11255 311619 flip = 0;
11256 311619 int32_t fdiv = frate/4;
11257
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 311619 times.
311619 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
11258
11259
1/2
✓ Branch 0 taken 311619 times.
✗ Branch 1 not taken.
311619 int32_t f2=get_qr(qr_NEWENEMYTILES)?
11260 311619 efrate:((clk>=(frate>>1))?1:0);
11261 311619 shadowtile = wpnsbuf[spr_shadow].tile;
11262
11263
1/2
✓ Branch 0 taken 311619 times.
✗ Branch 1 not taken.
311619 if(get_qr(qr_NEWENEMYTILES))
11264 {
11265 311619 shadowtile+=f2;
11266 311619 }
11267 else
11268 {
11269 shadowtile+=f2?1:0;
11270 }
11271
11272 311619 yofs+=shadowdistance;
11273 311619 yofs+=8;
11274 311619 }
11275
4/4
✓ Branch 0 taken 7896005 times.
✓ Branch 1 taken 215418 times.
✓ Branch 2 taken 8108388 times.
✓ Branch 3 taken 3035 times.
8111423 if((dmisc9 == e9tPOLSVOICE || dmisc9==e9tVIRE) && !get_qr(qr_POLVIRE_NO_SHADOW))
11276 {
11277 3035 flip = 0;
11278 3035 int32_t fdiv = frate/4;
11279
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3035 times.
3035 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
11280
11281
1/2
✓ Branch 0 taken 3035 times.
✗ Branch 1 not taken.
3035 int32_t f2=get_qr(qr_NEWENEMYTILES)?
11282 3035 efrate:((clk>=(frate>>1))?1:0);
11283 3035 shadowtile = wpnsbuf[spr_shadow].tile;
11284
11285
1/2
✓ Branch 0 taken 3035 times.
✗ Branch 1 not taken.
3035 if(get_qr(qr_NEWENEMYTILES))
11286 {
11287 3035 shadowtile+=f2;
11288 3035 }
11289 else
11290 {
11291 shadowtile+=f2?1:0;
11292 }
11293 3035 }
11294 8111423 enemy::drawshadow(dest, translucent);
11295 8111423 yofs=tempy;
11296 8111423 }
11297
11298 160669 int32_t eStalfos::takehit(weapon *w, weapon* realweap)
11299 {
11300 160669 int32_t wpnId = w->id;
11301 160669 int32_t wpnDir = w->dir;
11302
11303
4/4
✓ Branch 0 taken 1453 times.
✓ Branch 1 taken 159216 times.
✓ Branch 2 taken 631 times.
✓ Branch 3 taken 822 times.
160669 if(wpnId==wHammer && shield && (flags & guy_bkshield)
11304
6/8
✓ Branch 0 taken 407 times.
✓ Branch 1 taken 224 times.
✓ Branch 2 taken 407 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 276 times.
✓ Branch 5 taken 131 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 131 times.
631 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
11305
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 131 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 131 times.
131 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
11306 {
11307 276 shield = false;
11308 276 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
11309
11310
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 254 times.
276 if(get_qr(qr_BRKNSHLDTILES))
11311 254 o_tile=s_tile;
11312 276 }
11313
11314 160669 int32_t ret = enemy::takehit(w,realweap);
11315
11316
4/4
✓ Branch 0 taken 23525 times.
✓ Branch 1 taken 137144 times.
✓ Branch 2 taken 21774 times.
✓ Branch 3 taken 1751 times.
160669 if(sclk && dmisc2==e2tSPLITHIT)
11317 1751 sclk+=128; //Fuck these arbitrary values with no explanation. Fuck vires, too. -Z
11318
11319 160669 return ret;
11320 }
11321
11322 1061272 void eStalfos::charge_attack()
11323 {
11324
2/2
✓ Branch 0 taken 8516 times.
✓ Branch 1 taken 1052756 times.
1061272 if(slide())
11325 8516 return;
11326
11327
10/12
✓ Branch 0 taken 1052756 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1050352 times.
✓ Branch 3 taken 2404 times.
✓ Branch 4 taken 1020716 times.
✓ Branch 5 taken 29636 times.
✓ Branch 6 taken 999163 times.
✓ Branch 7 taken 21553 times.
✓ Branch 8 taken 992627 times.
✓ Branch 9 taken 6536 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 992627 times.
1052756 if(clk<0 || dir<0 || stunclk || watch || ceiling || frozenclock )
11328 60129 return;
11329
11330
2/2
✓ Branch 0 taken 40922 times.
✓ Branch 1 taken 951705 times.
992627 if(clk3<=0)
11331 {
11332 40922 fix_coords(true);
11333
11334
2/2
✓ Branch 0 taken 11132 times.
✓ Branch 1 taken 29790 times.
40922 if(!dashing)
11335 {
11336 29790 int32_t ldir = lined_up(7,false);
11337
11338
4/4
✓ Branch 0 taken 3397 times.
✓ Branch 1 taken 26393 times.
✓ Branch 2 taken 492 times.
✓ Branch 3 taken 2905 times.
29790 if(ldir!=-1 && canmove(ldir,false))
11339 {
11340 2905 dir=ldir;
11341 2905 dashing=true;
11342
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2905 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2905 if (dmisc10<=0 || replay_version_check(0,33) || get_qr(qr_ROPE_ENEMIES_SPEED_NOT_CONFIGURABLE))
11343 2905 step=zslongToFix(dstep*100)+1;
11344 else
11345 step=zslongToFix(dmisc10*100);
11346 2905 }
11347 26885 else newdir(4,0,0);
11348 29790 }
11349
11350
2/2
✓ Branch 0 taken 39330 times.
✓ Branch 1 taken 1592 times.
40922 if(!canmove(dir,false))
11351 {
11352 1592 step=zslongToFix(dstep*100);
11353 1592 newdir();
11354 1592 dashing=false;
11355 1592 }
11356
11357 40922 zfix div = step;
11358
11359
1/2
✓ Branch 0 taken 40922 times.
✗ Branch 1 not taken.
40922 if(div == 0)
11360 div = 1;
11361
11362 40922 clk3=(int32_t)(16.0/div);
11363 40922 return;
11364 }
11365
11366 951705 move(step);
11367 951705 --clk3;
11368 1061272 }
11369
11370 796110 void eStalfos::vire_hop()
11371 {
11372
2/2
✓ Branch 0 taken 379034 times.
✓ Branch 1 taken 417076 times.
796110 if(dmisc9!=e9tPOLSVOICE)
11373 {
11374
2/2
✓ Branch 0 taken 372449 times.
✓ Branch 1 taken 6585 times.
379034 if(sclk!=0)
11375 {
11376
2/2
✓ Branch 0 taken 2742 times.
✓ Branch 1 taken 3843 times.
6585 if (dmisc2==e2tSPLITHIT) return;
11377 3843 }
11378 376292 }
11379 417076 else sclk=0;
11380
11381
8/12
✓ Branch 0 taken 793368 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 793368 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 777885 times.
✓ Branch 5 taken 15483 times.
✓ Branch 6 taken 761476 times.
✓ Branch 7 taken 16409 times.
✓ Branch 8 taken 761476 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 761476 times.
793368 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
11382 31892 return;
11383
11384 761476 int32_t jump_width = (dmisc9==e9tPOLSVOICE) ? 2 : 1;
11385 int32_t jump_height;
11386
11387
1/2
✓ Branch 0 taken 761476 times.
✗ Branch 1 not taken.
761476 if ((dmisc10 <= 0))
11388 761476 jump_height = (dmisc9 == e9tPOLSVOICE) ? 27 : 16;
11389 else jump_height = dmisc10;
11390
11391 761476 y=floor_y;
11392
11393
2/2
✓ Branch 0 taken 735218 times.
✓ Branch 1 taken 26258 times.
761476 if(clk3<=0)
11394 {
11395 26258 fix_coords();
11396
11397 //z=0;
11398 //if we're not in the middle of a jump or if we can't complete the current jump in the current direction
11399 //if(clk2<=0 || !canmove(dir,(zfix)1,spw_floater,false) || (isSideViewGravity() && isOnSideviewPlatform()))
11400
9/10
✓ Branch 0 taken 4922 times.
✓ Branch 1 taken 21336 times.
✓ Branch 2 taken 4320 times.
✓ Branch 3 taken 602 times.
✓ Branch 4 taken 94 times.
✓ Branch 5 taken 4226 times.
✓ Branch 6 taken 42 times.
✓ Branch 7 taken 52 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 42 times.
26258 if(clk2<=0 || !canmove(dir,(zfix)1,spw_floater,false) || (isSideViewGravity() && (isOnSideviewPlatform() || !(moveflags & move_obeys_grav)))) //Vires in old quests
11401 22032 newdir(rate,homing,dmisc9==e9tPOLSVOICE ? spw_floater : spw_none);
11402
11403
2/2
✓ Branch 0 taken 4922 times.
✓ Branch 1 taken 21336 times.
26258 if(clk2<=0)
11404 {
11405 //z=0;
11406
6/6
✓ Branch 0 taken 19015 times.
✓ Branch 1 taken 2321 times.
✓ Branch 2 taken 18569 times.
✓ Branch 3 taken 446 times.
✓ Branch 4 taken 14491 times.
✓ Branch 5 taken 4078 times.
21336 if(!canmove(dir,(zfix)2,spw_none,false) || m_walkflag(x,y,spw_none, dir) || (zc_oldrand()&15)>=hrate)
11407 {
11408
11409
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17258 times.
17258 clk2=(wpn==ewBrang ? 1 : int32_t((16.0*jump_width)/step.getFloat()));
11410 17258 }
11411 21336 }
11412
11413
4/4
✓ Branch 0 taken 12099 times.
✓ Branch 1 taken 14159 times.
✓ Branch 2 taken 5069 times.
✓ Branch 3 taken 7030 times.
26258 if(dmisc9!=e9tPOLSVOICE && dir>=left) //if we're moving left or right
11414 {
11415 7030 clk2=int32_t((16.0*jump_width)/step.getFloat());
11416 7030 }
11417
11418 26258 clk3=int32_t(16.0/step.getFloat());
11419 26258 }
11420
11421 761476 --clk3;
11422
11423
3/4
✓ Branch 0 taken 361067 times.
✓ Branch 1 taken 400409 times.
✓ Branch 2 taken 361067 times.
✗ Branch 3 not taken.
761476 if(dmisc9==e9tPOLSVOICE || clk2>0)
11424 761476 move(step);
11425
11426 761476 floor_y=y;
11427 761476 clk2--;
11428
11429 //if we're in the middle of a jump
11430
6/6
✓ Branch 0 taken 624929 times.
✓ Branch 1 taken 136547 times.
✓ Branch 2 taken 257704 times.
✓ Branch 3 taken 367225 times.
✓ Branch 4 taken 110653 times.
✓ Branch 5 taken 147051 times.
761476 if(clk2>0 && (dir>=left || dmisc9==e9tPOLSVOICE))
11431 {
11432 477878 int32_t h = fixtoi(fixsin(itofix(clk2*128*step/(16*jump_width)))*jump_height);
11433
11434
4/4
✓ Branch 0 taken 99298 times.
✓ Branch 1 taken 378580 times.
✓ Branch 2 taken 6151 times.
✓ Branch 3 taken 93147 times.
477878 if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
11435 {
11436
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93147 times.
93147 if (moveflags & move_use_fake_z) fakez=h;
11437 93147 else z=h;
11438 93147 }
11439 else
11440 {
11441 384731 y=floor_y-h;
11442 384731 shadowdistance=h;
11443 }
11444 477878 }
11445 else
11446 283598 shadowdistance = 0;
11447 796110 }
11448
11449 143 void eStalfos::eathero()
11450 {
11451
5/8
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 69 times.
✓ Branch 2 taken 74 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 74 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 74 times.
143 if(!hashero && Hero.getEaten()==0 && Hero.getAction() != hopping && Hero.getAction() != swimming)
11452 {
11453 74 hashero=true;
11454 74 y=floor_y;
11455 74 z=0;
11456
11457
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if(Hero.isSwimming())
11458 {
11459 Hero.setX(x);
11460 Hero.setY(y);
11461 }
11462 else
11463 {
11464 74 x=Hero.getX();
11465 74 y=Hero.getY();
11466 }
11467
11468 74 clk2=0;
11469 74 }
11470 143 }
11471
11472 1480441 bool eStalfos::WeaponOut()
11473 {
11474
2/2
✓ Branch 0 taken 2414454 times.
✓ Branch 1 taken 626493 times.
3040947 for(int32_t i=0; i<Ewpns.Count(); i++)
11475 {
11476
3/4
✓ Branch 0 taken 853948 times.
✓ Branch 1 taken 1560506 times.
✓ Branch 2 taken 853948 times.
✗ Branch 3 not taken.
2414454 if(((weapon*)Ewpns.spr(i))->parentid==getUID() && Ewpns.spr(i)->id==ewBrang)
11477 {
11478 853948 return true;
11479 }
11480 1560506 }
11481
11482 626493 return false;
11483 1480441 }
11484
11485 369776 void eStalfos::KillWeapon()
11486 {
11487
2/2
✓ Branch 0 taken 316707 times.
✓ Branch 1 taken 369776 times.
686483 for(int32_t i=0; i<Ewpns.Count(); i++)
11488 {
11489
4/4
✓ Branch 0 taken 267955 times.
✓ Branch 1 taken 48752 times.
✓ Branch 2 taken 267137 times.
✓ Branch 3 taken 818 times.
316707 if(((weapon*)Ewpns.spr(i))->level==misc && Ewpns.spr(i)->id==ewBrang)
11490 {
11491 //only kill this Goriya's boomerang -DD
11492
2/2
✓ Branch 0 taken 399 times.
✓ Branch 1 taken 419 times.
818 if(((weapon *)Ewpns.spr(i))->parentid == getUID())
11493 {
11494 419 Ewpns.del(i);
11495 419 }
11496 818 }
11497 316707 }
11498 369776 }
11499
11500 void eStalfos::break_shield()
11501 {
11502 if(!shield)
11503 return;
11504
11505 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
11506 shield=false;
11507
11508 if(get_qr(qr_BRKNSHLDTILES))
11509 o_tile=s_tile;
11510 }
11511
11512 void eStalfos::repair_shield()
11513 {
11514 if (shield)
11515 return;
11516
11517 shield = true;
11518
11519 if (get_qr(qr_BRKNSHLDTILES))
11520 {
11521 if get_qr(qr_NEWENEMYTILES) o_tile = d->e_tile;
11522 else o_tile = d->tile;
11523 }
11524 }
11525
11526 14404 eKeese::eKeese(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
11527 14404 {
11528
1/2
✓ Branch 0 taken 14404 times.
✗ Branch 1 not taken.
14404 dir=(zc_oldrand()&7)+8;
11529
1/2
✓ Branch 0 taken 14404 times.
✗ Branch 1 not taken.
14404 step=0;
11530 14404 movestatus=1;
11531
3/4
✓ Branch 0 taken 11247 times.
✓ Branch 1 taken 3157 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11247 times.
14404 if (dmisc1 != 1 && dmisc19 > 0)
11532 {
11533 step = dmisc19/100.0;
11534 movestatus = 1;
11535 }
11536
1/2
✓ Branch 0 taken 14404 times.
✗ Branch 1 not taken.
14404 if (dmisc1 == 2) movestatus=2;
11537 14404 c=0;
11538 14404 clk4=0;
11539 //nets;
11540
1/2
✓ Branch 0 taken 14404 times.
✗ Branch 1 not taken.
14404 init_size_flags();
11541 14404 dummy_int[1]=0;
11542 14404 }
11543
11544 3691183 bool eKeese::animate(int32_t index)
11545 {
11546
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3691183 times.
3691183 if(switch_hooked) return enemy::animate(index);
11547
2/4
✓ Branch 0 taken 3691183 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3691183 times.
3691183 if(fallclk||drownclk) return enemy::animate(index);
11548
2/2
✓ Branch 0 taken 131109 times.
✓ Branch 1 taken 3560074 times.
3691183 if(dying)
11549 131109 return Dead(index);
11550
11551
2/2
✓ Branch 0 taken 3532905 times.
✓ Branch 1 taken 27169 times.
3560074 if(clk==0)
11552 {
11553 27169 removearmos(x,y);
11554 27169 }
11555
11556
2/2
✓ Branch 0 taken 1037646 times.
✓ Branch 1 taken 2522428 times.
3560074 if(dmisc1 == 1) //Walk style. 0 is keese, 1 is bat.
11557 {
11558 1037646 floater_walk(rate,hrate,dstep/100,(zfix)0,10,dmisc16,dmisc17);
11559 1037646 }
11560 else
11561 {
11562
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2522428 times.
2522428 if (dmisc18) floater_walk(rate,hrate,dstep/100,dmisc18/100.0,-1,dmisc16,dmisc17);
11563 2522428 else floater_walk(rate,hrate,dstep/100,dstep/1000,10,dmisc16,dmisc17);
11564 }
11565
11566
2/2
✓ Branch 0 taken 120338 times.
✓ Branch 1 taken 3439736 times.
3560074 if(dmisc2 == e2tKEESETRIB)
11567 {
11568
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 120338 times.
✓ Branch 2 taken 120147 times.
✓ Branch 3 taken 191 times.
120338 if(++clk4==(dmisc20>0?dmisc20:256))
11569 {
11570
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 105 times.
191 if(!m_walkflag(x,y,0, dir))
11571 {
11572 105 int32_t kids = guys.Count();
11573 105 bool success = false;
11574 105 int32_t id2=dmisc3;
11575 105 success = 0 != addenemy(screen_spawned,(zfix)x,(zfix)y,id2,-24);
11576
11577
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(success)
11578 {
11579
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(itemguy) // Hand down the carried item
11580 {
11581 int guycarryingitem = guys.Count()-1;
11582 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
11583 itemguy = false;
11584 }
11585
11586 105 ((enemy*)guys.spr(kids))->count_enemy = count_enemy;
11587 105 }
11588
11589 105 stop_bgsfx(index);
11590 105 return true;
11591 }
11592 else
11593 {
11594 86 clk4=0;
11595 }
11596 86 }
11597 120233 }
11598 // Keese Tribbles stay on the ground, so there's no problem when they transform.
11599
3/4
✓ Branch 0 taken 995121 times.
✓ Branch 1 taken 2444615 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 995121 times.
3439736 else if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
11600 {
11601
2/2
✓ Branch 0 taken 687068 times.
✓ Branch 1 taken 308053 times.
995121 if (get_qr(qr_OLD_KEESE_Z_AXIS))
11602 {
11603
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 687068 times.
687068 if (moveflags & move_use_fake_z)
11604 {
11605 fakez=int32_t(step/zslongToFix(dstep*100));
11606 // Some variance in keese flight heights when away from Hero
11607 fakez+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-128)/10));
11608
11609 }
11610 else
11611 {
11612 687068 z=int32_t(step/zslongToFix(dstep*100));
11613 // Some variance in keese flight heights when away from Hero
11614
2/2
✓ Branch 0 taken 503635 times.
✓ Branch 1 taken 183433 times.
687068 z+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-128)/10));
11615 }
11616 687068 }
11617 else
11618 {
11619
2/2
✓ Branch 0 taken 149242 times.
✓ Branch 1 taken 158811 times.
308053 if (moveflags & move_use_fake_z)
11620 {
11621 149242 fakez=int32_t(step/zslongToFix(dstep*100));
11622 // Some variance in keese flight heights when away from Hero
11623
2/2
✓ Branch 0 taken 132535 times.
✓ Branch 1 taken 16707 times.
149242 fakez+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-40)/4));
11624
11625 149242 }
11626 else
11627 {
11628 158811 z=int32_t(step/zslongToFix(dstep*100));
11629 // Some variance in keese flight heights when away from Hero
11630
2/2
✓ Branch 0 taken 16841 times.
✓ Branch 1 taken 141970 times.
158811 z+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-40)/4));
11631 }
11632 }
11633 995121 }
11634
11635 3559969 return enemy::animate(index);
11636 3691183 }
11637
11638 2931677 bool eKeese::can_drawshadow() const
11639 {
11640
4/4
✓ Branch 0 taken 1533959 times.
✓ Branch 1 taken 1397718 times.
✓ Branch 2 taken 17822 times.
✓ Branch 3 taken 1516137 times.
2931677 if(get_qr(qr_ENEMIESZAXIS) && step <= 0)
11641 17822 return false;
11642
11643 2913855 return enemy::can_drawshadow();
11644 2931677 }
11645 2246724 void eKeese::drawshadow(BITMAP *dest, bool translucent)
11646 {
11647 2246724 flip = 0;
11648
2/2
✓ Branch 0 taken 1561771 times.
✓ Branch 1 taken 684953 times.
2246724 if(!can_drawshadow())
11649 1561771 return;
11650 684953 int32_t tempy=yofs;
11651 684953 shadowtile = wpnsbuf[spr_shadow].tile+posframe;
11652
11653
2/2
✓ Branch 0 taken 166228 times.
✓ Branch 1 taken 518725 times.
684953 yofs+=zc_min(int32_t(step/zslongToFix(dstep*10)), 8);
11654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 684953 times.
684953 if(!get_qr(qr_ENEMIESZAXIS))
11655 {
11656 yofs+=int32_t(step/zslongToFix(dstep*10));
11657 }
11658
11659 684953 enemy::drawshadow(dest, translucent);
11660 684953 yofs=tempy;
11661 2246724 }
11662
11663 8413799 void eKeese::draw(BITMAP *dest)
11664 {
11665 8413799 update_enemy_frame();
11666 8413799 enemy::draw(dest);
11667 8413799 }
11668
11669 14404 void eKeese::init_size_flags()
11670 {
11671 14404 SIZEflags = d->SIZEflags;
11672
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14404 times.
14404 if (!(SIZEflags & OVERRIDE_HIT_X_OFFSET)) hxofs = 2;
11673
1/2
✓ Branch 0 taken 14404 times.
✗ Branch 1 not taken.
14404 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
11674
11675
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14404 times.
14404 if (!(SIZEflags & OVERRIDE_HIT_WIDTH)) hit_width = 12;
11676
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14404 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14404 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
11677
11678
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14404 times.
14404 if (!(SIZEflags & OVERRIDE_HIT_Y_OFFSET)) hyofs = 4;
11679
1/2
✓ Branch 0 taken 14404 times.
✗ Branch 1 not taken.
14404 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
11680
11681
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14404 times.
14404 if (!(SIZEflags & OVERRIDE_HIT_HEIGHT)) hit_height = 8;
11682
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14404 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14404 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
11683
11684
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 14404 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
14404 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
11685 // al_trace("Enemy txsz:%i\n", txsz);
11686
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 14404 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
14404 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
11687
11688
11689
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14404 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14404 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
11690
11691
1/2
✓ Branch 0 taken 14404 times.
✗ Branch 1 not taken.
14404 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
11692
1/2
✓ Branch 0 taken 14404 times.
✗ Branch 1 not taken.
14404 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
11693 {
11694 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
11695 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
11696 }
11697
11698
1/2
✓ Branch 0 taken 14404 times.
✗ Branch 1 not taken.
14404 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
11699 14404 }
11700
11701 20171 void eWizzrobe::submerge(bool set)
11702 {
11703
2/2
✓ Branch 0 taken 20024 times.
✓ Branch 1 taken 147 times.
20171 if(get_qr(qr_OLD_WIZZROBE_SUBMERGING))
11704 {
11705 20024 hxofs = set?1000:0;
11706 20024 return;
11707 }
11708
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
147 if(submerged == set) return;
11709 147 submerged = set;
11710
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 71 times.
147 if(set)
11711 76 hxofs+=1000;
11712 71 else hxofs -= 1000;
11713 20171 }
11714 5350 eWizzrobe::eWizzrobe(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
11715 5350 {
11716 5350 hxofs = 0;
11717 5350 submerged = false;
11718
2/2
✓ Branch 0 taken 2358 times.
✓ Branch 1 taken 2992 times.
5350 switch(dmisc1)
11719 {
11720 case 0:
11721 2992 submerge(true);
11722 2992 fading=fade_invisible;
11723 // Set clk to just before the 'reappear' threshold
11724
9/10
✓ Branch 0 taken 2991 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 2991 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 1184 times.
✓ Branch 5 taken 1808 times.
✓ Branch 6 taken 1184 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1807 times.
✓ Branch 9 taken 1 times.
2992 clk=zc_min(clk+(146+zc_max(0,dmisc5))+14,(146+zc_max(0,dmisc5))-1);
11725 2992 break;
11726
11727 default:
11728 2358 dir=(loadside==right)?right:left;
11729 2358 misc=-3;
11730 2358 break;
11731 }
11732
11733 //netst+2880;
11734 5350 charging=false;
11735 5350 firing=false;
11736 5350 fclk=0;
11737
2/2
✓ Branch 0 taken 2358 times.
✓ Branch 1 taken 2992 times.
5350 if(!dmisc1) frate=1200+146; //1200 = 20 seconds
11738
1/4
✓ Branch 0 taken 5350 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5350 if (SIZEflags != 0) init_size_flags();;
11739 5350 }
11740
11741 2081613 bool eWizzrobe::animate(int32_t index)
11742 {
11743
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2081613 times.
2081613 if(switch_hooked) return enemy::animate(index);
11744
2/4
✓ Branch 0 taken 2081613 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2081613 times.
2081613 if(fallclk||drownclk) return enemy::animate(index);
11745
2/2
✓ Branch 0 taken 38023 times.
✓ Branch 1 taken 2043590 times.
2081613 if(dying)
11746 {
11747 38023 return Dead(index);
11748 }
11749
11750
2/2
✓ Branch 0 taken 1976944 times.
✓ Branch 1 taken 66646 times.
2043590 if(clk==0)
11751 {
11752 66646 removearmos(x,y);
11753 66646 }
11754
11755
2/2
✓ Branch 0 taken 1019220 times.
✓ Branch 1 taken 1024370 times.
2043590 if(dmisc1) // Floating
11756 {
11757 1019220 wizzrobe_attack();
11758 1019220 }
11759 else // Teleporting
11760 {
11761
5/6
✓ Branch 0 taken 1017286 times.
✓ Branch 1 taken 7084 times.
✓ Branch 2 taken 11087 times.
✓ Branch 3 taken 1006199 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 11087 times.
1024370 if(watch || (!get_qr(qr_WIZZROBES_DONT_OBEY_STUN) && stunclk))
11762 {
11763 7084 fading=0;
11764 7084 submerge(false);
11765 7084 solid_update(false);
11766 7084 }
11767
8/8
✓ Branch 0 taken 983365 times.
✓ Branch 1 taken 6240 times.
✓ Branch 2 taken 5313 times.
✓ Branch 3 taken 5151 times.
✓ Branch 4 taken 5006 times.
✓ Branch 5 taken 4247 times.
✓ Branch 6 taken 4109 times.
✓ Branch 7 taken 3855 times.
1017286 else switch(clk)
11768 {
11769 case 0:
11770
2/2
✓ Branch 0 taken 1117 times.
✓ Branch 1 taken 5123 times.
6240 if(!dmisc2)
11771 {
11772 // Wizzrobe Misc4 controls whether wizzrobes can teleport on top of solid combos,
11773 // but should not appear on dungeon walls.
11774
2/2
✓ Branch 0 taken 413 times.
✓ Branch 1 taken 4710 times.
5123 if ( FFCore.getQuestHeaderInfo(vZelda) <= 0x190 ) place_on_axis(true, false); //1.84, and probably 1.90 wizzrobes should NEVER appear in dungeon walls.-Z (1.84 confirmed, 15th January, 2019 by Chris Miller).
11775
2/2
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 4486 times.
4710 else if (editorflags&ENEMY_FLAG5)
11776 {
11777 //2.10 Windrobe
11778 //randomise location and face Hero
11779 224 int32_t t=0;
11780 224 bool placed=false;
11781
11782
4/4
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 367 times.
✓ Branch 2 taken 367 times.
✓ Branch 3 taken 224 times.
591 while(!placed && t<160)
11783 {
11784
2/2
✓ Branch 0 taken 280 times.
✓ Branch 1 taken 87 times.
367 if(isdungeon(screen_spawned))
11785 {
11786 280 x=((zc_oldrand()%12)+2)*16;
11787 280 y=((zc_oldrand()%7)+2)*16;
11788 280 }
11789 else
11790 {
11791 87 x=((zc_oldrand()%14)+1)*16;
11792 87 y=((zc_oldrand()%9)+1)*16;
11793 }
11794
11795 367 std::tie(x, y) = translate_screen_coordinates_to_world(screen_spawned, x, y);
11796
11797
6/6
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 244 times.
✓ Branch 2 taken 187 times.
✓ Branch 3 taken 57 times.
✓ Branch 4 taken 143 times.
✓ Branch 5 taken 224 times.
611 if(!m_walkflag(x,y,spw_door, dir)&&((abs(x-Hero.getX())>=32)||(abs(y-Hero.getY())>=32)))
11798 {
11799 224 placed=true;
11800 224 }
11801
11802 367 ++t;
11803 }
11804
11805
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 163 times.
224 if(abs(x-Hero.getX())<abs(y-Hero.getY()))
11806 {
11807
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 14 times.
61 if(y<Hero.getY())
11808 {
11809 47 dir=down;
11810 47 }
11811 else
11812 {
11813 14 dir=up;
11814 }
11815 61 }
11816 else
11817 {
11818
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 72 times.
163 if(x<Hero.getX())
11819 {
11820 72 dir=right;
11821 72 }
11822 else
11823 {
11824 91 dir=left;
11825 }
11826 }
11827
11828
1/2
✓ Branch 0 taken 224 times.
✗ Branch 1 not taken.
224 if(!placed) // can't place him, he's gone
11829 return true;
11830
11831
11832 //wizzrobe_attack(); //Complaint about 2.10 Windrobes not behaving as they did in 2.10. Let's try it this way. -Z
11833 //wizzrobe_attack_for_real(); //doing this makes them fire twice. The rest is correct.
11834 224 }
11835 4486 else place_on_axis(true, dmisc4!=0);
11836 5123 }
11837 else
11838 {
11839 1117 int32_t t=0;
11840 1117 bool placed=false;
11841
11842
4/4
✓ Branch 0 taken 1117 times.
✓ Branch 1 taken 2443 times.
✓ Branch 2 taken 2443 times.
✓ Branch 3 taken 1117 times.
3560 while(!placed && t<160)
11843 {
11844
2/2
✓ Branch 0 taken 1340 times.
✓ Branch 1 taken 1103 times.
2443 if(isdungeon(screen_spawned))
11845 {
11846 1340 x=((zc_oldrand()%12)+2)*16;
11847 1340 y=((zc_oldrand()%7)+2)*16;
11848 1340 }
11849 else
11850 {
11851 1103 x=((zc_oldrand()%14)+1)*16;
11852 1103 y=((zc_oldrand()%9)+1)*16;
11853 }
11854
11855 2443 std::tie(x, y) = translate_screen_coordinates_to_world(screen_spawned, x, y);
11856
11857
6/6
✓ Branch 0 taken 1130 times.
✓ Branch 1 taken 1313 times.
✓ Branch 2 taken 898 times.
✓ Branch 3 taken 415 times.
✓ Branch 4 taken 1326 times.
✓ Branch 5 taken 1117 times.
3756 if(!m_walkflag(x,y,spw_door, dir)&&((abs(x-Hero.getX())>=32)||(abs(y-Hero.getY())>=32)))
11858 {
11859 1117 placed=true;
11860 1117 }
11861
11862 2443 ++t;
11863 }
11864
11865
2/2
✓ Branch 0 taken 386 times.
✓ Branch 1 taken 731 times.
1117 if(abs(x-Hero.getX())<abs(y-Hero.getY()))
11866 {
11867
2/2
✓ Branch 0 taken 238 times.
✓ Branch 1 taken 148 times.
386 if(y<Hero.getY())
11868 {
11869 238 dir=down;
11870 238 }
11871 else
11872 {
11873 148 dir=up;
11874 }
11875 386 }
11876 else
11877 {
11878
2/2
✓ Branch 0 taken 340 times.
✓ Branch 1 taken 391 times.
731 if(x<Hero.getX())
11879 {
11880 340 dir=right;
11881 340 }
11882 else
11883 {
11884 391 dir=left;
11885 }
11886 }
11887
11888
1/2
✓ Branch 0 taken 1117 times.
✗ Branch 1 not taken.
1117 if(!placed) // can't place him, he's gone
11889 return true;
11890 }
11891
11892 6240 fading=fade_flicker;
11893 6240 submerge(false);
11894 6240 solid_update(false);
11895 6240 break;
11896
11897 case 64:
11898 5313 fading=0;
11899 5313 charging=true;
11900 5313 break;
11901
11902 case 73:
11903 5151 charging=false;
11904 5151 firing=40;
11905 5151 break;
11906
11907 case 83:
11908 5006 wizzrobe_attack_for_real();
11909 5006 break;
11910
11911 case 119:
11912 4247 firing=false;
11913 4247 charging=true;
11914 4247 break;
11915
11916 case 128:
11917 4109 fading=fade_flicker;
11918 4109 charging=false;
11919 4109 break;
11920
11921 case 146:
11922 3855 fading=fade_invisible;
11923 3855 submerge(true);
11924 3855 solid_update(false);
11925
11926 [[fallthrough]];
11927 default:
11928
4/4
✓ Branch 0 taken 987060 times.
✓ Branch 1 taken 160 times.
✓ Branch 2 taken 980971 times.
✓ Branch 3 taken 6249 times.
987220 if(clk>=(146+zc_max(0,dmisc5)))
11929 6249 clk=-1;
11930
11931 987220 break;
11932 }
11933 }
11934
11935 2043590 return enemy::animate(index);
11936 2081613 }
11937
11938 7929 void eWizzrobe::wizzrobe_attack_for_real()
11939 {
11940
1/2
✓ Branch 0 taken 7929 times.
✗ Branch 1 not taken.
7929 if(wpn==0) // Edited enemies
11941 return;
11942
11943
2/2
✓ Branch 0 taken 1983 times.
✓ Branch 1 taken 5946 times.
7929 if(dmisc2 == 0) //normal weapon
11944 {
11945 5946 addEwpn(x,y,z,wpn,0,wdp,dir,getUID(), 0, fakez);
11946 5946 sfx(firesfx, pan(x));
11947 5946 }
11948
2/2
✓ Branch 0 taken 995 times.
✓ Branch 1 taken 988 times.
1983 else if(dmisc2 == 1) // ring of fire
11949 {
11950 995 addEwpn(x,y,z,wpn,0,wdp,up,getUID(), 0, fakez);
11951 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11952 995 addEwpn(x,y,z,wpn,0,wdp,down,getUID(), 0, fakez);
11953 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11954 995 addEwpn(x,y,z,wpn,0,wdp,left,getUID(), 0, fakez);
11955 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11956 995 addEwpn(x,y,z,wpn,0,wdp,right,getUID(), 0, fakez);
11957 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11958 995 addEwpn(x,y,z,wpn,0,wdp,l_up,getUID(), 0, fakez);
11959 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11960 995 addEwpn(x,y,z,wpn,0,wdp,r_up,getUID(), 0, fakez);
11961 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11962 995 addEwpn(x,y,z,wpn,0,wdp,l_down,getUID(), 0, fakez);
11963 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11964 995 addEwpn(x,y,z,wpn,0,wdp,r_down,getUID(), 0, fakez);
11965 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11966 //this block of code was buggy and flat out doesn't match the default wpnsfx for these weapons.
11967 //i've compromised by making all old quest use this code chunk by default.
11968
1/2
✓ Branch 0 taken 995 times.
✗ Branch 1 not taken.
995 if (FFCore.quest_format[vGuys] < 51)
11969 {
11970 995 sfx(WAV_FIRE, pan(x));
11971
2/2
✓ Branch 0 taken 488 times.
✓ Branch 1 taken 507 times.
995 if (get_qr(qr_8WAY_SHOT_SFX_DEP)) sfx(WAV_FIRE,pan(x));
11972 else
11973 {
11974
3/17
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 68 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 420 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
507 switch (wpn)
11975 {
11976 19 case ewFireball: sfx(40, pan(x)); break;
11977 case ewBrang: sfx(4, pan(x)); break; //Ghost.zh has 0?
11978 case ewSword: sfx(20, pan(x)); break; //Ghost.zh has 0?
11979 case ewRock: sfx(51, pan(x)); break;
11980 68 case ewMagic: sfx(32, pan(x)); break;
11981 case ewBomb: sfx(3, pan(x)); break; //Ghost.zh has 0?
11982 case ewSBomb: sfx(3, pan(x)); break; //Ghost.zh has 0?
11983 case ewLitBomb: sfx(21, pan(x)); break; //Ghost.zh has 0?
11984 case ewLitSBomb: sfx(21, pan(x)); break; //Ghost.zh has 0?
11985 case ewFireTrail: sfx(13, pan(x)); break;
11986 420 case ewFlame: sfx(13, pan(x)); break;
11987 case ewWind: sfx(32, pan(x)); break;
11988 case ewFlame2: sfx(13, pan(x)); break;
11989 case ewFlame2Trail: sfx(13, pan(x)); break;
11990 case ewIce: sfx(44, pan(x)); break;
11991 case ewFireball2: sfx(40, pan(x)); break; //fireball (rising)
11992 default: sfx(WAV_FIRE, pan(x)); break;
11993 }
11994 }
11995 995 }
11996 else
11997 {
11998 sfx(firesfx, pan(x));
11999 }
12000 995 }
12001
2/2
✓ Branch 0 taken 971 times.
✓ Branch 1 taken 17 times.
988 else if(dmisc2==2) // summons specific enemy
12002 {
12003 971 int32_t bc=0;
12004
12005
2/2
✓ Branch 0 taken 10497 times.
✓ Branch 1 taken 971 times.
11468 for(int32_t gc=0; gc<guys.Count(); gc++)
12006 {
12007
2/2
✓ Branch 0 taken 5302 times.
✓ Branch 1 taken 5195 times.
10497 if((((enemy*)guys.spr(gc))->id) == dmisc3)
12008 {
12009 5195 ++bc;
12010 5195 }
12011 10497 }
12012
12013
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 963 times.
971 if(bc<=40)
12014 {
12015 963 int32_t kids = guys.Count();
12016 963 int32_t bats=(zc_oldrand()%3)+1;
12017
12018
2/2
✓ Branch 0 taken 1965 times.
✓ Branch 1 taken 963 times.
2928 for(int32_t i=0; i<bats; i++)
12019 {
12020 // Summon bats (or anything)
12021
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1965 times.
1965 if(addchild(screen_spawned, x,y,dmisc3,-10, this))
12022 1965 ((enemy*)guys.spr(kids+i))->count_enemy = false;
12023 1965 }
12024 963 sfx(firesfx, pan(x));
12025 963 }
12026 971 }
12027
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 else if(dmisc2==3) //summon from layer
12028 {
12029
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(count_layer_enemies(screen_spawned)==0)
12030 {
12031 return;
12032 }
12033
12034 17 int32_t kids = guys.Count();
12035
12036
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(kids<200)
12037 {
12038 17 int32_t newguys=(zc_oldrand()%3)+1;
12039 17 bool summoned=false;
12040
12041
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 17 times.
49 for(int32_t i=0; i<newguys; i++)
12042 {
12043 32 int32_t id2=vbound(random_layer_enemy(screen_spawned),eSTART,eMAXGUYS-1);
12044 32 int32_t x2=0;
12045 32 int32_t y2=0;
12046
12047
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 for(int32_t k=0; k<20; ++k)
12048 {
12049 36 x2=16*((zc_oldrand()%12)+2);
12050 36 y2=16*((zc_oldrand()%7)+2);
12051
12052
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 21 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 32 times.
72 if(!m_walkflag(x2,y2,0, dir) && (abs(x2-Hero.getX())>=32 || abs(y2-Hero.getY())>=32))
12053 {
12054
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(addchild_z(screen_spawned,x2,y2,get_qr(qr_ENEMIESZAXIS) ? 64 : 0,id2,-10, this))
12055 {
12056 32 ((enemy*)guys.spr(kids+i))->count_enemy = false;
12057
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 25 times.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
32 if (get_qr(qr_ENEMIESZAXIS) && (((enemy*)guys.spr(kids+i))->moveflags & move_use_fake_z))
12058 {
12059 ((enemy*)guys.spr(kids+i))->fakez = 64;
12060 ((enemy*)guys.spr(kids+i))->z = 0;
12061 }
12062 32 }
12063
12064 32 summoned=true;
12065 32 break;
12066 }
12067 4 }
12068 32 }
12069
12070
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(summoned)
12071 {
12072 17 sfx(firesfx, pan(x));
12073 17 }
12074 17 }
12075 17 }
12076 7929 }
12077
12078
12079 1019220 void eWizzrobe::wizzrobe_attack()
12080 {
12081
10/12
✓ Branch 0 taken 982487 times.
✓ Branch 1 taken 36733 times.
✓ Branch 2 taken 982487 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 937882 times.
✓ Branch 5 taken 44605 times.
✓ Branch 6 taken 934499 times.
✓ Branch 7 taken 3383 times.
✓ Branch 8 taken 932879 times.
✓ Branch 9 taken 1620 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 932879 times.
1019220 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
12082 86341 return;
12083
12084
3/8
✓ Branch 0 taken 893341 times.
✓ Branch 1 taken 39538 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 893341 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
932879 if(clk3<=0 || ((clk3&31)==0 && !canmove(dir,(zfix)1,spw_door,false) && !misc))
12085 {
12086 39538 fix_coords();
12087
12088
5/5
✓ Branch 0 taken 5496 times.
✓ Branch 1 taken 1050 times.
✓ Branch 2 taken 16081 times.
✓ Branch 3 taken 13008 times.
✓ Branch 4 taken 3903 times.
39538 switch(misc)
12089 {
12090 case 1: //walking
12091
2/2
✓ Branch 0 taken 10364 times.
✓ Branch 1 taken 2644 times.
13008 if(!m_walkflag(x,y,spw_door, dir))
12092 2644 misc=0;
12093 else
12094 {
12095 10364 clk3=16;
12096
12097
2/2
✓ Branch 0 taken 8966 times.
✓ Branch 1 taken 1398 times.
10364 if(!canmove(dir,(zfix)1,spw_wizzrobe,false))
12098 {
12099 1398 wizzrobe_newdir(0);
12100 1398 }
12101 }
12102
12103 13008 break;
12104
12105 case 2: //phasing
12106 {
12107 3903 int32_t jx=x;
12108 3903 int32_t jy=y;
12109 3903 int32_t jdir=-1;
12110
12111
5/5
✓ Branch 0 taken 1973 times.
✓ Branch 1 taken 484 times.
✓ Branch 2 taken 472 times.
✓ Branch 3 taken 482 times.
✓ Branch 4 taken 492 times.
3903 switch(zc_oldrand()&7)
12112 {
12113 case 0:
12114 484 jx-=32;
12115 484 jy-=32;
12116 484 jdir=15;
12117 484 break;
12118
12119 case 1:
12120 472 jx+=32;
12121 472 jy-=32;
12122 472 jdir=9;
12123 472 break;
12124
12125 case 2:
12126 482 jx+=32;
12127 482 jy+=32;
12128 482 jdir=11;
12129 482 break;
12130
12131 case 3:
12132 492 jx-=32;
12133 492 jy+=32;
12134 492 jdir=13;
12135 492 break;
12136 }
12137
12138
10/10
✓ Branch 0 taken 1930 times.
✓ Branch 1 taken 1973 times.
✓ Branch 2 taken 1724 times.
✓ Branch 3 taken 206 times.
✓ Branch 4 taken 1597 times.
✓ Branch 5 taken 127 times.
✓ Branch 6 taken 1385 times.
✓ Branch 7 taken 212 times.
✓ Branch 8 taken 1140 times.
✓ Branch 9 taken 245 times.
3903 if(jdir>0 && jx>=32 && jx<=208 && jy>=32 && jy<=128)
12139 {
12140 1140 misc=3;
12141 1140 clk3=32;
12142 1140 dir=jdir;
12143 1140 break;
12144 }
12145 2763 }
12146 [[fallthrough]];
12147 case 3:
12148 3813 dir&=3;
12149 3813 misc=0;
12150 [[fallthrough]];
12151 case 0:
12152 19894 wizzrobe_newdir(64);
12153 [[fallthrough]];
12154 default:
12155
2/2
✓ Branch 0 taken 21886 times.
✓ Branch 1 taken 3504 times.
25390 if(!canmove(dir,(zfix)1,spw_door,false))
12156 {
12157
2/2
✓ Branch 0 taken 3265 times.
✓ Branch 1 taken 239 times.
3504 if(canmove(dir,(zfix)15,spw_wizzrobe,false))
12158 {
12159 3265 misc=1;
12160 3265 clk3=16;
12161 3265 }
12162 else
12163 {
12164 239 wizzrobe_newdir(64);
12165 239 misc=0;
12166 239 clk3=32;
12167 }
12168 3504 }
12169 else
12170 {
12171 21886 clk3=32;
12172 }
12173
12174 25390 break;
12175 }
12176
12177
2/2
✓ Branch 0 taken 35060 times.
✓ Branch 1 taken 4478 times.
39538 if(misc<0)
12178 4478 ++misc;
12179 39538 }
12180
12181 932879 --clk3;
12182
12183
3/3
✓ Branch 0 taken 248377 times.
✓ Branch 1 taken 620599 times.
✓ Branch 2 taken 63903 times.
932879 switch(misc)
12184 {
12185 case 1:
12186 case 3:
12187 248377 step=1;
12188 248377 break;
12189
12190 case 2:
12191 63903 step=0;
12192 63903 break;
12193
12194 default:
12195 620599 step=0.5;
12196 620599 break;
12197
12198 }
12199
12200 932879 move(step);
12201
12202 // if(d->misc1 && misc<=0 && clk3==28)
12203
5/6
✓ Branch 0 taken 932879 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 620599 times.
✓ Branch 3 taken 312280 times.
✓ Branch 4 taken 599052 times.
✓ Branch 5 taken 21547 times.
932879 if(dmisc1 && misc<=0 && clk3==28)
12204 {
12205
2/2
✓ Branch 0 taken 16835 times.
✓ Branch 1 taken 4712 times.
21547 if(dmisc2 != 1)
12206 {
12207
2/2
✓ Branch 0 taken 14907 times.
✓ Branch 1 taken 1928 times.
16835 if(lined_up(8,false) == dir)
12208 {
12209 // addEwpn(x,y,z,wpn,0,wdp,dir,getUID());
12210 // sfx(WAV_WAND,pan(x));
12211 1928 wizzrobe_attack_for_real();
12212 1928 fclk=30;
12213 1928 }
12214 16835 }
12215 else
12216 {
12217
2/2
✓ Branch 0 taken 3717 times.
✓ Branch 1 taken 995 times.
4712 if((zc_oldrand()%500)>=400)
12218 {
12219 995 wizzrobe_attack_for_real();
12220 995 fclk=30;
12221 995 }
12222 }
12223 21547 }
12224
12225
4/4
✓ Branch 0 taken 517526 times.
✓ Branch 1 taken 415353 times.
✓ Branch 2 taken 4050 times.
✓ Branch 3 taken 513476 times.
932879 if(misc==0 && (zc_oldrand()&127)==0)
12226 4050 misc=2;
12227
12228
4/4
✓ Branch 0 taken 67953 times.
✓ Branch 1 taken 864926 times.
✓ Branch 2 taken 64512 times.
✓ Branch 3 taken 3441 times.
932879 if(misc==2 && clk3==4)
12229 3441 fix_coords();
12230
12231
2/4
✓ Branch 0 taken 932879 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 932879 times.
932879 if(!(charging||firing)) //should never be charging or firing for these wizzrobes
12232 {
12233
2/2
✓ Branch 0 taken 849597 times.
✓ Branch 1 taken 83282 times.
932879 if(fclk>0)
12234 {
12235 83282 --fclk;
12236 83282 }
12237 932879 }
12238
12239 1019220 }
12240
12241 21531 void eWizzrobe::wizzrobe_newdir(int32_t homing)
12242 {
12243 // Wizzrobes shouldn't move to the edge of the screen;
12244 // if they're already there, they should move toward the center
12245
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 21498 times.
21531 if(x<32)
12246 33 dir=right;
12247
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 21494 times.
21498 else if(x>=world_w-32)
12248 4 dir=left;
12249
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 21492 times.
21494 else if(y<32)
12250 2 dir=down;
12251
2/2
✓ Branch 0 taken 21487 times.
✓ Branch 1 taken 5 times.
21492 else if(y>=world_h-32)
12252 5 dir=up;
12253 else
12254 21487 newdir(4,homing,spw_wizzrobe);
12255 21531 }
12256
12257 2099229 void eWizzrobe::draw(BITMAP *dest)
12258 {
12259 // if(d->misc1 && (misc==1 || misc==3) && (clk3&1) && hp>0 && !watch && !stunclk) // phasing
12260
13/14
✓ Branch 0 taken 1042483 times.
✓ Branch 1 taken 1056746 times.
✓ Branch 2 taken 817873 times.
✓ Branch 3 taken 224610 times.
✓ Branch 4 taken 132112 times.
✓ Branch 5 taken 910371 times.
✓ Branch 6 taken 130752 times.
✓ Branch 7 taken 1360 times.
✓ Branch 8 taken 129926 times.
✓ Branch 9 taken 826 times.
✓ Branch 10 taken 125018 times.
✓ Branch 11 taken 4908 times.
✓ Branch 12 taken 125018 times.
✗ Branch 13 not taken.
2099229 if(dmisc1 && (misc==1 || misc==3) && (clk3&1) && hp>0 && !watch && !stunclk && !frozenclock) // phasing
12261 125018 return;
12262
12263 1974211 int32_t tempint=dummy_int[1];
12264 1974211 bool tempbool1=dummy_bool[1];
12265 1974211 bool tempbool2=dummy_bool[2];
12266 1974211 dummy_int[1]=fclk;
12267 1974211 dummy_bool[1]=charging;
12268 1974211 dummy_bool[2]=firing;
12269 1974211 update_enemy_frame();
12270 1974211 dummy_int[1]=tempint;
12271 1974211 dummy_bool[1]=tempbool1;
12272 1974211 dummy_bool[2]=tempbool2;
12273 1974211 enemy::draw(dest);
12274 2099229 }
12275
12276 209 eDodongo::eDodongo(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12277 209 {
12278 209 fading=fade_flash_die;
12279
6/8
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 155 times.
✓ Branch 2 taken 54 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 54 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
✓ Branch 7 taken 50 times.
209 if(dir==down&&y>=128)
12280 {
12281 4 dir=up;
12282 4 }
12283
12284
5/8
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 147 times.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 62 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 62 times.
209 if(dir==right&&x>=208)
12285 {
12286 dir=left;
12287 }
12288
1/4
✓ Branch 0 taken 209 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
209 if (SIZEflags != 0) init_size_flags();;
12289 209 }
12290
12291 133094 bool eDodongo::animate(int32_t index)
12292 {
12293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133094 times.
133094 if(switch_hooked) return enemy::animate(index);
12294
2/2
✓ Branch 0 taken 4054 times.
✓ Branch 1 taken 129040 times.
133094 if(dying)
12295 {
12296 4054 return Dead(index);
12297 }
12298
12299
2/2
✓ Branch 0 taken 128441 times.
✓ Branch 1 taken 599 times.
129040 if(clk==0)
12300 {
12301 599 removearmos(x,y);
12302 599 }
12303
12304
2/2
✓ Branch 0 taken 11424 times.
✓ Branch 1 taken 117616 times.
129040 if(clk2) // ate a bomb
12305 {
12306
2/2
✓ Branch 0 taken 11305 times.
✓ Branch 1 taken 119 times.
11424 if(--clk2==0)
12307 119 hp-=misc; // store bomb's power in misc
12308 11424 }
12309 else
12310 117616 constant_walk(rate,homing,spw_clipright);
12311
12312 129040 hit_width = (dir<=down) ? 16 : 32;
12313 // hysz = (dir>=left) ? 16 : 32;
12314
12315 129040 return enemy::animate(index);
12316 133094 }
12317
12318 133544 void eDodongo::draw(BITMAP *dest)
12319 {
12320 133544 tile=o_tile;
12321
12322
2/2
✓ Branch 0 taken 3077 times.
✓ Branch 1 taken 130467 times.
133544 if(clk<0)
12323 {
12324 3077 enemy::drawzcboss(dest);
12325 3077 return;
12326 }
12327
12328 130467 update_enemy_frame();
12329 130467 enemy::drawzcboss(dest);
12330
12331
2/2
✓ Branch 0 taken 54026 times.
✓ Branch 1 taken 76441 times.
130467 if(dummy_int[1]!=0) //additional tiles
12332 {
12333 76441 tile+=dummy_int[1]; //second tile is previous tile
12334 76441 xofs-=16; //new xofs change
12335 76441 enemy::drawzcboss(dest);
12336 76441 xofs+=16;
12337 76441 }
12338
12339 133544 }
12340
12341 8681 int32_t eDodongo::takehit(weapon *w, weapon* realweap)
12342 {
12343 8681 int32_t wpnId = w->id;
12344 8681 int32_t power = w->power;
12345 8681 int32_t wpnx = w->x;
12346 8681 int32_t wpny = w->y;
12347
12348
5/12
✓ Branch 0 taken 8681 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8681 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2676 times.
✓ Branch 5 taken 6005 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2676 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
8681 if(dying || clk<0 || clk2>0 || (superman && !(superman>1 && wpnId==wSBomb)))
12349 6005 return 0;
12350
12351
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 851 times.
✓ Branch 2 taken 1631 times.
✓ Branch 3 taken 17 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 177 times.
2676 switch(wpnId)
12352 {
12353 case wPhantom:
12354 return 0;
12355
12356 case wFire:
12357 case wBait:
12358 case wWhistle:
12359 case wWind:
12360 case wSSparkle:
12361 case wFSparkle:
12362 return 0;
12363
12364 case wLitBomb:
12365 case wLitSBomb:
12366
6/6
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 564 times.
✓ Branch 2 taken 307 times.
✓ Branch 3 taken 544 times.
✓ Branch 4 taken 732 times.
✓ Branch 5 taken 119 times.
851 if(abs(wpnx-((dir==right)?x+16:x)) > 7 || abs(wpny-y) > 7)
12367 732 return 0;
12368
12369 119 clk2=96;
12370 119 misc=power;
12371
12372
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 3 times.
119 if(wpnId==wLitSBomb)
12373 3 item_set=isSBOMB100;
12374
12375 119 return 1;
12376
12377 case wBomb:
12378 case wSBomb:
12379
6/6
✓ Branch 0 taken 536 times.
✓ Branch 1 taken 1095 times.
✓ Branch 2 taken 463 times.
✓ Branch 3 taken 1168 times.
✓ Branch 4 taken 587 times.
✓ Branch 5 taken 1044 times.
1631 if(abs(wpnx-((dir==right)?x+16:x)) > 8 || abs(wpny-y) > 8)
12380 587 return 0;
12381
12382 1044 stunclk=160;
12383 1044 misc=wpnId; // store wpnId
12384 1044 return 1;
12385
12386 case wSword:
12387
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 92 times.
177 if(stunclk)
12388 {
12389 92 sfx(WAV_EHIT,pan(x));
12390 92 hp=0;
12391 92 item_set = (misc==wSBomb) ? isSBOMB100 : isBOMB100;
12392 92 fading=0; // don't flash
12393 92 return 1;
12394 }
12395
12396 [[fallthrough]];
12397 default:
12398 102 sfx(WAV_CHINK,pan(x));
12399 102 }
12400
12401 102 return 1;
12402 8681 }
12403
12404 48 eDodongo2::eDodongo2(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12405 48 {
12406 48 fading=fade_flash_die;
12407 //nets+5180;
12408 48 previous_dir=-1;
12409
6/8
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 13 times.
48 if(dir==down&&y>=128)
12410 {
12411 1 dir=up;
12412 1 }
12413
12414
5/8
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 12 times.
48 if(dir==right&&x>=208)
12415 {
12416 dir=left;
12417 }
12418
1/4
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
48 if (SIZEflags != 0) init_size_flags();;
12419 48 }
12420
12421 39398 bool eDodongo2::animate(int32_t index)
12422 {
12423
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39398 times.
39398 if(switch_hooked) return enemy::animate(index);
12424
2/2
✓ Branch 0 taken 1158 times.
✓ Branch 1 taken 38240 times.
39398 if(dying)
12425 {
12426 1158 return Dead(index);
12427 }
12428
12429
2/2
✓ Branch 0 taken 38073 times.
✓ Branch 1 taken 167 times.
38240 if(clk==0)
12430 {
12431 167 removearmos(x,y);
12432 167 }
12433
12434
2/2
✓ Branch 0 taken 4032 times.
✓ Branch 1 taken 34208 times.
38240 if(clk2) // ate a bomb
12435 {
12436
2/2
✓ Branch 0 taken 3990 times.
✓ Branch 1 taken 42 times.
4032 if(--clk2==0)
12437 42 hp-=misc; // store bomb's power in misc
12438 4032 }
12439 else
12440 34208 constant_walk(rate,homing,spw_clipbottomright);
12441
12442 38240 hit_width = (dir<=down) ? 16 : 32;
12443 38240 hit_height = (dir>=left) ? 16 : 32;
12444 38240 hxofs=(dir>=left)?-8:0;
12445 38240 hyofs=(dir<left)?-8:0;
12446
12447 38240 return enemy::animate(index);
12448 39398 }
12449
12450 39601 void eDodongo2::draw(BITMAP *dest)
12451 {
12452
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 38833 times.
39601 if(clk<0)
12453 {
12454 768 enemy::drawzcboss(dest);
12455 768 return;
12456 }
12457
12458 38833 int32_t tempx=xofs;
12459 38833 int32_t tempy=yofs;
12460 38833 update_enemy_frame();
12461 38833 enemy::drawzcboss(dest);
12462 38833 tile+=dummy_int[1]; //second tile change
12463 38833 xofs+=dummy_int[2]; //new xofs change
12464 38833 yofs+=dummy_int[3]; //new yofs change
12465 38833 enemy::drawzcboss(dest);
12466 38833 xofs=tempx;
12467 38833 yofs=tempy;
12468 39601 }
12469
12470 3929 int32_t eDodongo2::takehit(weapon *w, weapon* realweap)
12471 {
12472 3929 int32_t wpnId = w->id;
12473 3929 int32_t power = w->power;
12474 3929 int32_t wpnx = w->x;
12475 3929 int32_t wpny = w->y;
12476
12477
5/8
✓ Branch 0 taken 3929 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3929 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1552 times.
✓ Branch 5 taken 2377 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1552 times.
3929 if(dying || clk<0 || clk2>0 || superman)
12478 2377 return 0;
12479
12480
5/6
✓ Branch 0 taken 346 times.
✓ Branch 1 taken 321 times.
✓ Branch 2 taken 693 times.
✓ Branch 3 taken 31 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 161 times.
1552 switch(wpnId)
12481 {
12482 case wPhantom:
12483 return 0;
12484
12485 case wFire:
12486 case wBait:
12487 case wWhistle:
12488 case wWind:
12489 case wSSparkle:
12490 case wFSparkle:
12491 346 return 0;
12492
12493 case wLitBomb:
12494 case wLitSBomb:
12495
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 81 times.
321 switch(dir)
12496 {
12497 case up:
12498
4/4
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 4 times.
81 if(abs(wpnx-x) > 7 || abs(wpny-(y-8)) > 7)
12499 77 return 0;
12500
12501 4 break;
12502
12503 case down:
12504
4/4
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 38 times.
✓ Branch 2 taken 71 times.
✓ Branch 3 taken 6 times.
77 if(abs(wpnx-x) > 7 || abs(wpny-(y+8)) > 7)
12505 71 return 0;
12506
12507 6 break;
12508
12509 case left:
12510
4/4
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 40 times.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 16 times.
82 if(abs(wpnx-(x-8)) > 7 || abs(wpny-y) > 7)
12511 66 return 0;
12512
12513 16 break;
12514
12515 case right:
12516
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 65 times.
✓ Branch 2 taken 65 times.
✓ Branch 3 taken 16 times.
81 if(abs(wpnx-(x+8)) > 7 || abs(wpny-y) > 7)
12517 65 return 0;
12518
12519 16 break;
12520 }
12521
12522 // if(abs(wpnx-((dir==right)?x+8:(dir==left)?x-8:0)) > 7 || abs(wpny-((dir==down)?y+8:(dir==up)?y-8:0)) > 7)
12523 // return 0;
12524 42 clk2=96;
12525 42 misc=power;
12526
12527
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if(wpnId==wLitSBomb)
12528 item_set=isSBOMB100;
12529
12530 42 return 1;
12531
12532 case wBomb:
12533 case wSBomb:
12534
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 176 times.
✓ Branch 2 taken 168 times.
✓ Branch 3 taken 185 times.
✓ Branch 4 taken 164 times.
693 switch(dir)
12535 {
12536 case up:
12537
4/4
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 55 times.
✓ Branch 2 taken 84 times.
✓ Branch 3 taken 92 times.
176 if(abs(wpnx-x) > 7 || abs(wpny-(y-8)) > 7)
12538 84 return 0;
12539
12540 92 break;
12541
12542 case down:
12543
4/4
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 87 times.
✓ Branch 2 taken 113 times.
✓ Branch 3 taken 55 times.
168 if(abs(wpnx-x) > 7 || abs(wpny-(y+8)) > 7)
12544 113 return 0;
12545
12546 55 break;
12547
12548 case left:
12549
4/4
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 80 times.
✓ Branch 2 taken 80 times.
✓ Branch 3 taken 105 times.
185 if(abs(wpnx-(x-8)) > 7 || abs(wpny-y) > 7)
12550 80 return 0;
12551
12552 105 break;
12553
12554 case right:
12555
4/4
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 67 times.
✓ Branch 2 taken 71 times.
✓ Branch 3 taken 93 times.
164 if(abs(wpnx-(x+8)) > 7 || abs(wpny-y) > 7)
12556 71 return 0;
12557
12558 93 break;
12559 }
12560
12561 345 stunclk=160;
12562 345 misc=wpnId; // store wpnId
12563 345 return 1;
12564
12565 case wSword:
12566
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 34 times.
161 if(stunclk)
12567 {
12568 34 sfx(WAV_EHIT,pan(x));
12569 34 hp=0;
12570 34 item_set = (misc==wSBomb) ? isSBOMB100 : isBOMB100;
12571 34 fading=0; // don't flash
12572 34 return 1;
12573 }
12574
12575 [[fallthrough]];
12576 default:
12577 158 sfx(WAV_CHINK,pan(x));
12578 158 }
12579
12580 158 return 1;
12581 3929 }
12582
12583 126 eAquamentus::eAquamentus(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)//enemy((zfix)176,(zfix)64,Id,Clk)
12584 126 {
12585 //these are here to bypass compiler warnings about unused arguments
12586
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if ( !(editorflags & ENEMY_FLAG5) )
12587 {
12588
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 position_relative_to_screen(x, y, dmisc1 ? 64 : 176, 64);
12589 126 }
12590 else { x = X; y = Y; }
12591
12592 //nets+5940;
12593
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 45 times.
126 if(get_qr(qr_NEWENEMYTILES))
12594 {
12595 81 }
12596 else
12597 {
12598
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 7 times.
45 if(dmisc1)
12599 {
12600 7 flip=1;
12601 7 }
12602 }
12603
12604
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)+1;
12605 126 clk3=32;
12606 126 clk2=0;
12607 126 clk4=clk;
12608 126 dir=left;
12609
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
126 if (SIZEflags != 0) init_size_flags();;
12610 126 }
12611
12612 71899 bool eAquamentus::animate(int32_t index)
12613 {
12614
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71899 times.
71899 if(switch_hooked) return enemy::animate(index);
12615
2/2
✓ Branch 0 taken 2092 times.
✓ Branch 1 taken 69807 times.
71899 if(dying)
12616 2092 return Dead(index);
12617
12618 // fbx=x+((id==eRAQUAM)?4:-4);
12619
2/2
✓ Branch 0 taken 69490 times.
✓ Branch 1 taken 317 times.
69807 if(clk==0)
12620 {
12621 317 removearmos(x,y);
12622 317 }
12623
12624 69807 fbx=x;
12625
12626 /*
12627 if (get_qr(qr_NEWENEMYTILES)&&id==eLAQUAM)
12628 {
12629 fbx+=16;
12630 }
12631 */
12632
2/2
✓ Branch 0 taken 69357 times.
✓ Branch 1 taken 450 times.
69807 if(--clk3==0)
12633 {
12634 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,up+1);
12635 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,0);
12636 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,down+1);
12637 450 addEwpn(fbx,y,z,wpn,2,wdp,up,getUID(), 0, fakez);
12638 450 addEwpn(fbx,y,z,wpn,2,wdp,8,getUID(), 0, fakez);
12639 450 addEwpn(fbx,y,z,wpn,2,wdp,down,getUID(), 0, fakez);
12640 450 sfx(wpnsfx(wpn),pan(x));
12641 450 }
12642
12643
4/4
✓ Branch 0 taken 21363 times.
✓ Branch 1 taken 48444 times.
✓ Branch 2 taken 21018 times.
✓ Branch 3 taken 345 times.
69807 if(clk3<-80 && !(zc_oldrand()&63))
12644 {
12645 345 clk3=32;
12646 345 }
12647
12648 69807 int screen_x = x.getInt()%256;
12649
2/2
✓ Branch 0 taken 68690 times.
✓ Branch 1 taken 1117 times.
69807 if(!((clk4+1)&63))
12650 {
12651 1117 int32_t d2=(zc_oldrand()%3)+1;
12652
12653
2/2
✓ Branch 0 taken 365 times.
✓ Branch 1 taken 752 times.
1117 if(d2>=left)
12654 {
12655 752 dir=d2;
12656 752 }
12657
12658
2/2
✓ Branch 0 taken 732 times.
✓ Branch 1 taken 385 times.
1117 if(dmisc1)
12659 {
12660
2/2
✓ Branch 0 taken 347 times.
✓ Branch 1 taken 38 times.
385 if(screen_x<=40)
12661 {
12662 38 dir=right;
12663 38 }
12664
12665
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 if(screen_x>=104)
12666 {
12667 dir=left;
12668 }
12669 385 }
12670 else
12671 {
12672
2/2
✓ Branch 0 taken 711 times.
✓ Branch 1 taken 21 times.
732 if(screen_x<=136)
12673 {
12674 21 dir=right;
12675 21 }
12676
12677
2/2
✓ Branch 0 taken 698 times.
✓ Branch 1 taken 34 times.
732 if(screen_x>=200)
12678 {
12679 34 dir=left;
12680 34 }
12681 }
12682 1117 }
12683
12684
4/4
✓ Branch 0 taken 67907 times.
✓ Branch 1 taken 1900 times.
✓ Branch 2 taken 59366 times.
✓ Branch 3 taken 8541 times.
69807 if(clk4>=-1 && !((clk4+1)&7))
12685 {
12686
2/2
✓ Branch 0 taken 4546 times.
✓ Branch 1 taken 3995 times.
8541 if(dir==left)
12687 {
12688 4546 x-=1;
12689 4546 }
12690 else
12691 {
12692 3995 x+=1;
12693 }
12694 8541 }
12695
12696 69807 clk4=(clk4+1)%256;
12697
12698 69807 return enemy::animate(index);
12699 71899 }
12700
12701 72310 void eAquamentus::draw(BITMAP *dest)
12702 {
12703
2/2
✓ Branch 0 taken 44994 times.
✓ Branch 1 taken 27316 times.
72310 if(get_qr(qr_NEWENEMYTILES))
12704 {
12705 44994 xofs=(dmisc1?-16:0);
12706
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44994 times.
✓ Branch 2 taken 18341 times.
✓ Branch 3 taken 26653 times.
44994 if ( do_animation ) tile=o_tile+((clk&24)>>2)+(clk3>-32?(clk3>0?40:80):0);
12707
12708
2/2
✓ Branch 0 taken 1312 times.
✓ Branch 1 taken 43682 times.
44994 if(dying)
12709 {
12710 1312 xofs=0;
12711 1312 enemy::draw(dest);
12712 1312 }
12713 else
12714 {
12715 43682 drawblock(dest,15);
12716 }
12717 44994 }
12718 else
12719 {
12720 27316 int32_t xblockofs=((dmisc1)?-16:16);
12721 27316 xofs=0;
12722
12723
4/4
✓ Branch 0 taken 26634 times.
✓ Branch 1 taken 682 times.
✓ Branch 2 taken 780 times.
✓ Branch 3 taken 25854 times.
27316 if(clk<0 || dying)
12724 {
12725 1462 enemy::draw(dest);
12726 1462 return;
12727 }
12728
1/2
✓ Branch 0 taken 25854 times.
✗ Branch 1 not taken.
25854 if ( do_animation )
12729 {
12730 // face (0=firing, 2=resting)
12731 25854 tile=o_tile+((clk3>0)?0:2);
12732 25854 enemy::draw(dest);
12733 // tail (
12734 25854 tile=o_tile+((clk&16)?1:3);
12735 25854 xofs=xblockofs;
12736 25854 enemy::draw(dest);
12737 // body
12738 25854 yofs+=16;
12739 25854 xofs=0;
12740 25854 tile=o_tile+((clk&16)?20:22);
12741 25854 enemy::draw(dest);
12742 25854 xofs=xblockofs;
12743 25854 tile=o_tile+((clk&16)?21:23);
12744 25854 enemy::draw(dest);
12745 25854 yofs-=16;
12746 25854 }
12747 else enemy::draw(dest);
12748 }
12749 72310 }
12750
12751 23834 bool eAquamentus::hit(weapon *w)
12752 {
12753
3/6
✓ Branch 0 taken 23834 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23834 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23834 times.
23834 if(!w->scriptcoldet || w->fallclk || w->drownclk) return false;
12754
12755
2/2
✓ Branch 0 taken 4201 times.
✓ Branch 1 taken 19633 times.
23834 switch(w->id)
12756 {
12757 case wBeam:
12758 case wRefBeam:
12759 case wMagic:
12760 4201 hit_height=32;
12761 4201 }
12762
12763
4/4
✓ Branch 0 taken 22740 times.
✓ Branch 1 taken 1094 times.
✓ Branch 2 taken 17546 times.
✓ Branch 3 taken 5194 times.
23834 bool ret = (dying || hclk>0) ? false : sprite::hit(w);
12764 23834 hit_height=16;
12765 23834 return ret;
12766
12767 23834 }
12768
12769 93 eGohma::eGohma(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) // enemy((zfix)128,(zfix)48,Id,0)
12770 93 {
12771
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 if ( !(editorflags & ENEMY_FLAG5) )
12772 {
12773
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 position_relative_to_screen(x, y, 128, 48);
12774 93 }
12775 else { x = X; y = Y; }
12776
12777 93 Clk=Clk;
12778
2/4
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
93 if(flags & guy_fade_flicker)
12779 {
12780 clk=0;
12781 superman = 1;
12782 fading=fade_flicker;
12783 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
12784 }
12785
3/4
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 51 times.
✓ Branch 3 taken 42 times.
93 else if(flags & guy_fade_instant)
12786 {
12787 42 clk=0;
12788 42 }
12789 93 hxofs=-16;
12790 93 hit_width=48;
12791 93 clk4=0;
12792
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
93 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)+1;
12793
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 dir=zc_oldrand()%3+1;
12794
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
93 if (SIZEflags != 0) init_size_flags();;
12795
12796 //nets+5340;
12797 93 }
12798
12799 70891 bool eGohma::animate(int32_t index)
12800 {
12801
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70891 times.
70891 if(switch_hooked) return enemy::animate(index);
12802
2/2
✓ Branch 0 taken 1226 times.
✓ Branch 1 taken 69665 times.
70891 if(dying)
12803 1226 return Dead(index);
12804
12805
2/2
✓ Branch 0 taken 69629 times.
✓ Branch 1 taken 36 times.
69665 if(fading)
12806 {
12807
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 1 times.
36 if(++clk4 > 60)
12808 {
12809 35 clk4=0;
12810 35 superman=0;
12811 35 fading=0;
12812 35 clk=0;
12813
12814 35 }
12815 1 else return enemy::animate(index);
12816 35 }
12817
12818
2/2
✓ Branch 0 taken 69314 times.
✓ Branch 1 taken 350 times.
69664 if(clk==0)
12819 {
12820
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 350 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
350 if (activated_handle && !activated_handle->is_rpos()) removearmos(x,y);
12821 else
12822 {
12823
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 350 times.
350 removearmos(zc_max(x-16, 0_zf),y);
12824 350 did_armos = false;
12825 350 removearmos(x,y);
12826 350 did_armos = false;
12827
1/2
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
350 removearmos(zc_min(x+16, 255_zf),y);
12828 }
12829 350 }
12830
12831
2/2
✓ Branch 0 taken 68878 times.
✓ Branch 1 taken 786 times.
69664 if(clk<0) return enemy::animate(index);
12832
12833 // Movement clk must be separate from animation clk because of the Clock item
12834
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68878 times.
68878 if(!watch)
12835 68878 clk4++;
12836
12837
2/2
✓ Branch 0 taken 67846 times.
✓ Branch 1 taken 1032 times.
68878 if((clk4&63)==0)
12838 {
12839
2/2
✓ Branch 0 taken 546 times.
✓ Branch 1 taken 486 times.
1032 if(clk4&64)
12840 546 dir^=1;
12841 else
12842 486 dir=zc_oldrand()%3+1;
12843 1032 }
12844
12845
2/2
✓ Branch 0 taken 67761 times.
✓ Branch 1 taken 1117 times.
68878 if((clk&63)==3)
12846 {
12847
2/2
✓ Branch 0 taken 882 times.
✓ Branch 1 taken 235 times.
1117 switch(dmisc1)
12848 {
12849 case 1:
12850 235 addEwpn(x,y+2,z,wpn,3,wdp,left,getUID(), 0, fakez);
12851 235 addEwpn(x,y+2,z,wpn,3,wdp,8,getUID(), 0, fakez);
12852 235 addEwpn(x,y+2,z,wpn,3,wdp,right,getUID(), 0, fakez);
12853 235 sfx(wpnsfx(wpn),pan(x));
12854 235 break;
12855
12856 default:
12857
3/4
✓ Branch 0 taken 882 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 128 times.
✓ Branch 3 taken 754 times.
882 if(dmisc1 != 1 && dmisc1 != 2)
12858 {
12859 754 addEwpn(x,y+2,z,wpn,3,wdp,8,getUID(), 0, fakez);
12860 754 sfx(wpnsfx(wpn),pan(x));
12861 754 sfx(wpnsfx(wpn),pan(x));
12862 754 }
12863
12864 882 break;
12865 }
12866 1117 }
12867
12868
6/6
✓ Branch 0 taken 8027 times.
✓ Branch 1 taken 60851 times.
✓ Branch 2 taken 7611 times.
✓ Branch 3 taken 416 times.
✓ Branch 4 taken 5396 times.
✓ Branch 5 taken 2215 times.
68878 if((dmisc1 == 2)&& clk3>=16 && clk3<116)
12869 {
12870
2/2
✓ Branch 0 taken 290 times.
✓ Branch 1 taken 1925 times.
2215 if(!(clk3%8))
12871 {
12872 290 FireBreath(true);
12873 290 }
12874 2215 }
12875
12876
2/2
✓ Branch 0 taken 34399 times.
✓ Branch 1 taken 34479 times.
68878 if(clk4&1)
12877 34479 move((zfix)1);
12878
12879
2/2
✓ Branch 0 taken 68728 times.
✓ Branch 1 taken 150 times.
68878 if(++clk3>=400)
12880 150 clk3=0;
12881
12882 68878 return enemy::animate(index);
12883 70891 }
12884
12885 70889 void eGohma::draw(BITMAP *dest)
12886 {
12887 70889 tile=o_tile;
12888
12889
4/4
✓ Branch 0 taken 70103 times.
✓ Branch 1 taken 786 times.
✓ Branch 2 taken 1226 times.
✓ Branch 3 taken 68877 times.
70889 if(clk<0 || dying)
12890 {
12891 2012 enemy::drawzcboss(dest);
12892 2012 return;
12893 }
12894
12895
2/2
✓ Branch 0 taken 53472 times.
✓ Branch 1 taken 15405 times.
68877 if(get_qr(qr_NEWENEMYTILES))
12896 {
12897 ///if ( do_animation )
12898 //Yuck. Gohma can just not have this capability right now.
12899 // left side
12900 53472 xofs=-16;
12901 53472 flip=0;
12902 // if(clk&16) tile=180;
12903 // else { tile=182; flip=1; }
12904 53472 tile+=(3*((clk&48)>>4));
12905 53472 enemy::drawzcboss(dest);
12906
12907 // right side
12908 53472 xofs=16;
12909 // tile=(180+182)-tile;
12910 53472 tile=o_tile;
12911 53472 tile+=(3*((clk&48)>>4))+2;
12912 53472 enemy::drawzcboss(dest);
12913
12914 // body
12915 53472 xofs=0; //Gohma may need more adjustments for SIZEflags. -Z 14 Aug 2020
12916 53472 tile=o_tile;
12917
12918 // tile+=(3*((clk&24)>>3))+2;
12919
2/2
✓ Branch 0 taken 2975 times.
✓ Branch 1 taken 50497 times.
53472 if(clk3<16)
12920 2975 tile+=7;
12921
2/2
✓ Branch 0 taken 15890 times.
✓ Branch 1 taken 34607 times.
50497 else if(clk3<116)
12922 15890 tile+=10;
12923
2/2
✓ Branch 0 taken 2051 times.
✓ Branch 1 taken 32556 times.
34607 else if(clk3<132)
12924 2051 tile+=7;
12925 else
12926 32556 tile+=((clk3-132)&24)?4:1;
12927
12928 53472 enemy::drawzcboss(dest);
12929
12930 53472 }
12931 else
12932 {
12933 // left side
12934 15405 xofs=-16;
12935 15405 flip=0;
12936
12937
2/2
✓ Branch 0 taken 7615 times.
✓ Branch 1 taken 7790 times.
15405 if(!(clk&16))
12938 {
12939 7790 tile+=2;
12940 7790 flip=1;
12941 7790 }
12942
12943 15405 enemy::draw(dest);
12944
12945 // right side
12946 15405 tile=o_tile;
12947 15405 xofs=16;
12948
12949
2/2
✓ Branch 0 taken 7790 times.
✓ Branch 1 taken 7615 times.
15405 if((clk&16)) tile+=2;
12950
12951 // tile=(180+182)-tile;
12952 15405 enemy::draw(dest);
12953
12954 // body
12955 15405 tile=o_tile;
12956 15405 xofs=0;
12957
12958
2/2
✓ Branch 0 taken 912 times.
✓ Branch 1 taken 14493 times.
15405 if(clk3<16)
12959 912 tile+=4;
12960
2/2
✓ Branch 0 taken 4882 times.
✓ Branch 1 taken 9611 times.
14493 else if(clk3<116)
12961 4882 tile+=5;
12962
2/2
✓ Branch 0 taken 585 times.
✓ Branch 1 taken 9026 times.
9611 else if(clk3<132)
12963 585 tile+=4;
12964 9026 else tile+=((clk3-132)&8)?3:1;
12965
12966 15405 enemy::draw(dest);
12967
12968 }
12969 70889 }
12970
12971 578 int32_t eGohma::takehit(weapon *w, weapon* realweap)
12972 {
12973 578 int32_t wpnId = w->id;
12974 578 int32_t power = w->power;
12975 578 int32_t wpnx = w->x;
12976 578 int32_t wpnDir = w->dir;
12977 578 int32_t def = defenditemclassNew(wpnId, &power, w, realweap);
12978
12979
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 421 times.
578 if(def < 0)
12980 {
12981
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 421 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 367 times.
✓ Branch 5 taken 54 times.
✓ Branch 6 taken 364 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 328 times.
✓ Branch 9 taken 36 times.
421 if(!((wpnDir==up || wpnDir==l_up || wpnDir==r_up) && abs(int32_t(x)-wpnx)<=8 && clk3>=16 && clk3<116))
12982 {
12983 93 sfx(WAV_CHINK,pan(x));
12984 93 return 1;
12985 }
12986 328 }
12987
12988 485 return enemy::takehit(w, realweap);
12989 578 }
12990
12991 327 eLilDig::eLilDig(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12992 327 {
12993 327 count_enemy=(id==(id&0xFFF));
12994 //nets+4360+(((id&0xFF)-eDIGPUP2)*40);
12995
1/4
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
327 if (SIZEflags != 0) init_size_flags();;
12996 327 }
12997
12998 124050 bool eLilDig::animate(int32_t index)
12999 {
13000
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124050 times.
124050 if(switch_hooked) return enemy::animate(index);
13001
2/2
✓ Branch 0 taken 4410 times.
✓ Branch 1 taken 119640 times.
124050 if(dying)
13002 4410 return Dead(index);
13003
13004
2/2
✓ Branch 0 taken 7105 times.
✓ Branch 1 taken 112535 times.
119640 if(clk==0)
13005 {
13006 7105 removearmos(x,y);
13007 7105 }
13008
13009
2/2
✓ Branch 0 taken 80994 times.
✓ Branch 1 taken 38646 times.
119640 if(misc<=128)
13010 {
13011
2/2
✓ Branch 0 taken 1161 times.
✓ Branch 1 taken 37485 times.
38646 if(!(++misc&31))
13012 1161 step+=0.25;
13013 38646 }
13014
13015 119640 variable_walk_8(rate,homing,hrate,spw_floater);
13016 119640 return enemy::animate(index);
13017 124050 }
13018
13019 124268 void eLilDig::draw(BITMAP *dest)
13020 {
13021 124268 tile = o_tile;
13022 // tile = 160;
13023 124268 int32_t fdiv = frate/4;
13024
1/2
✓ Branch 0 taken 124268 times.
✗ Branch 1 not taken.
124268 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13025
2/2
✓ Branch 0 taken 91457 times.
✓ Branch 1 taken 32811 times.
124268 int32_t f2=get_qr(qr_NEWENEMYTILES)?
13026 124268 efrate:((clk>=(frate>>1))?1:0);
13027
13028
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124268 times.
124268 if ( do_animation )
13029 {
13030
2/2
✓ Branch 0 taken 91457 times.
✓ Branch 1 taken 32811 times.
124268 if(get_qr(qr_NEWENEMYTILES))
13031 {
13032
9/9
✓ Branch 0 taken 11370 times.
✓ Branch 1 taken 10699 times.
✓ Branch 2 taken 10722 times.
✓ Branch 3 taken 12015 times.
✓ Branch 4 taken 10070 times.
✓ Branch 5 taken 9554 times.
✓ Branch 6 taken 8255 times.
✓ Branch 7 taken 10033 times.
✓ Branch 8 taken 8739 times.
91457 switch(dir-8) //directions get screwed up after 8. *shrug*
13033 {
13034 case up: //u
13035 11370 flip=0;
13036 11370 break;
13037
13038 case l_up: //d
13039 10699 flip=0;
13040 10699 tile+=4;
13041 10699 break;
13042
13043 case l_down: //l
13044 10722 flip=0;
13045 10722 tile+=8;
13046 10722 break;
13047
13048 case left: //r
13049 12015 flip=0;
13050 12015 tile+=12;
13051 12015 break;
13052
13053 case r_down: //ul
13054 10070 flip=0;
13055 10070 tile+=20;
13056 10070 break;
13057
13058 case down: //ur
13059 9554 flip=0;
13060 9554 tile+=24;
13061 9554 break;
13062
13063 case r_up: //dl
13064 8255 flip=0;
13065 8255 tile+=28;
13066 8255 break;
13067
13068 case right: //dr
13069 10033 flip=0;
13070 10033 tile+=32;
13071 10033 break;
13072 }
13073
13074 91457 tile+=f2;
13075 91457 }
13076 else
13077 {
13078 32811 tile+=(clk>=6)?1:0;
13079 }
13080 124268 }
13081
13082 124268 enemy::draw(dest);
13083 124268 }
13084
13085 80 eBigDig::eBigDig(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13086 80 {
13087
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 init_size_flags();
13088 80 }
13089
13090 29662 bool eBigDig::animate(int32_t index)
13091 {
13092
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29662 times.
29662 if(switch_hooked) return enemy::animate(index);
13093
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29662 times.
29662 if(dying)
13094 return Dead(index);
13095
13096
2/2
✓ Branch 0 taken 25558 times.
✓ Branch 1 taken 4104 times.
29662 if(clk==0)
13097 {
13098 4104 removearmos(x,y);
13099 4104 }
13100
13101
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29534 times.
✓ Branch 2 taken 64 times.
✓ Branch 3 taken 64 times.
29662 switch(misc)
13102 {
13103 case 0:
13104 29534 variable_walk_8(rate,homing,hrate,spw_floater,-8,-16,23,23);
13105 29534 break;
13106
13107 case 1:
13108 64 ++misc;
13109 64 break;
13110
13111 case 2:
13112
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 64 times.
175 for(int32_t i=0; i<dmisc5; i++)
13113 {
13114 111 addenemy(screen_spawned,x,y,dmisc1+0x1000,-15);
13115 111 }
13116
13117
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 64 times.
94 for(int32_t i=0; i<dmisc6; i++)
13118 {
13119 30 addenemy(screen_spawned,x,y,dmisc2+0x1000,-15);
13120 30 }
13121
13122
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 64 times.
94 for(int32_t i=0; i<dmisc7; i++)
13123 {
13124 30 addenemy(screen_spawned,x,y,dmisc3+0x1000,-15);
13125 30 }
13126
13127
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 64 times.
94 for(int32_t i=0; i<dmisc8; i++)
13128 {
13129 30 addenemy(screen_spawned,x,y,dmisc4+0x1000,-15);
13130 30 }
13131
13132
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 2 times.
64 if(itemguy) // Hand down the carried item
13133 {
13134 2 int guycarryingitem = guys.Count()-1;
13135 2 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
13136 2 itemguy = false;
13137 2 }
13138
13139 64 stop_bgsfx(index);
13140
13141
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 if(deadsfx > 0) sfx(deadsfx,pan(x));
13142
13143 64 return true;
13144 }
13145
13146 29598 return enemy::animate(index);
13147 29662 }
13148
13149 29658 void eBigDig::draw(BITMAP *dest)
13150 {
13151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29658 times.
29658 if(anim!=aDIG)
13152 {
13153 update_enemy_frame();
13154 xofs-=8;
13155 yofs-=8;
13156 drawblock(dest,15);
13157 xofs+=8;
13158 yofs+=8;
13159 return;
13160 }
13161
13162 29658 tile = o_tile;
13163 29658 int32_t fdiv = frate/4;
13164
1/2
✓ Branch 0 taken 29658 times.
✗ Branch 1 not taken.
29658 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13165
13166
2/2
✓ Branch 0 taken 16161 times.
✓ Branch 1 taken 13497 times.
29658 int32_t f2=get_qr(qr_NEWENEMYTILES)?
13167 29658 efrate:((clk>=(frate>>1))?1:0);
13168
13169
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29658 times.
29658 if ( do_animation )
13170 {
13171
2/2
✓ Branch 0 taken 16161 times.
✓ Branch 1 taken 13497 times.
29658 if(get_qr(qr_NEWENEMYTILES))
13172 {
13173
9/9
✓ Branch 0 taken 1688 times.
✓ Branch 1 taken 1684 times.
✓ Branch 2 taken 2031 times.
✓ Branch 3 taken 1910 times.
✓ Branch 4 taken 2041 times.
✓ Branch 5 taken 2043 times.
✓ Branch 6 taken 1514 times.
✓ Branch 7 taken 1009 times.
✓ Branch 8 taken 2241 times.
16161 switch(dir-8) //directions get screwed up after 8. *shrug*
13174 {
13175 case up: //u
13176 1688 flip=0;
13177 1688 break;
13178
13179 case l_up: //d
13180 1684 flip=0;
13181 1684 tile+=8;
13182 1684 break;
13183
13184 case l_down: //l
13185 2031 flip=0;
13186 2031 tile+=40;
13187 2031 break;
13188
13189 case left: //r
13190 1910 flip=0;
13191 1910 tile+=48;
13192 1910 break;
13193
13194 case r_down: //ul
13195 2041 flip=0;
13196 2041 tile+=80;
13197 2041 break;
13198
13199 case down: //ur
13200 2043 flip=0;
13201 2043 tile+=88;
13202
13203 2043 break;
13204
13205 case r_up: //dl
13206 1514 flip=0;
13207 1514 tile+=120;
13208 1514 break;
13209
13210 case right: //dr
13211 2241 flip=0;
13212 2241 tile+=128;
13213 2241 break;
13214 }
13215
13216 16161 tile+=(f2*2);
13217 16161 }
13218 else
13219 {
13220 13497 tile+=(f2)?0:2;
13221 13497 flip=(clk&1)?1:0;
13222 }
13223 29658 }
13224
13225 29658 xofs-=8;
13226 29658 yofs-=8;
13227 29658 drawblock(dest,15);
13228 29658 xofs+=8;
13229 29658 yofs+=8;
13230 29658 }
13231
13232 869 int32_t eBigDig::takehit(weapon *w, weapon* realweap)
13233 {
13234 869 int32_t wpnId = w->id;
13235
13236
3/4
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 805 times.
✓ Branch 2 taken 64 times.
✗ Branch 3 not taken.
869 if(wpnId==wWhistle && misc==0)
13237 {
13238 64 misc = 1;
13239 64 w->hit_pierce(this, 0, false);
13240 64 }
13241
13242 869 return 0;
13243 }
13244
13245 80 void eBigDig::init_size_flags()
13246 {
13247 80 SIZEflags = d->SIZEflags;
13248
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
80 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
13249 // al_trace("Enemy txsz:%i\n", txsz);
13250
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
80 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
13251
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
80 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0) hit_width = d->hxsz;
13252 80 else hit_width = 32;
13253
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
80 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0) hit_height = d->hysz;
13254 80 else hit_height = 32;
13255
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
80 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0) hzsz = d->hzsz;
13256 80 else hzsz = 16; // hard to jump.
13257
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
13258 80 else hxofs = -8;
13259
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
13260 80 else hyofs = -8;
13261 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
13262
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = d->xofs;
13263
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
13264 {
13265 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
13266 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
13267 }
13268
13269
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = d->zofs;
13270 80 }
13271
13272 13 eGanon::eGanon(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13273 13 {
13274 13 hxofs=hyofs=8;
13275
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if (editorflags & ENEMY_FLAG3)
13276 {
13277 hxofs = 4;
13278 hyofs = 4;
13279 hit_width = 24;
13280 hit_height = 24;
13281 SIZEflags|=OVERRIDE_HIT_WIDTH;
13282 SIZEflags|=OVERRIDE_HIT_HEIGHT;
13283 }
13284 13 hzsz=16; //can't be jumped.
13285 13 clk2=70;
13286 13 misc=-1;
13287
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 mapscr* scr = get_scr(screen_spawned);
13288
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
13 mainguy=(!getmapflag(scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (scr->flags9&fBELOWRETURN));
13289 13 }
13290
13291 18254 bool eGanon::animate(int32_t index) //DO NOT ADD a check for do_animation to this version of GANON!! -Z
13292 {
13293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18254 times.
18254 if(dying)
13294
13295 return Dead(index);
13296
13297
2/2
✓ Branch 0 taken 18182 times.
✓ Branch 1 taken 72 times.
18254 if(clk==0)
13298 {
13299 72 removearmos(x,y);
13300 72 }
13301
13302
6/7
✓ Branch 0 taken 3607 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12680 times.
✓ Branch 3 taken 13 times.
✓ Branch 4 taken 984 times.
✓ Branch 5 taken 960 times.
✓ Branch 6 taken 10 times.
18254 switch(misc)
13303 {
13304 case -1:
13305 13 misc=0;
13306 [[fallthrough]];
13307 case 0:
13308
4/4
✓ Branch 0 taken 708 times.
✓ Branch 1 taken 11985 times.
✓ Branch 2 taken 535 times.
✓ Branch 3 taken 173 times.
12693 if(++clk2>72 && !(zc_oldrand()&3))
13309 {
13310 173 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
13311 173 sfx(wpnsfx(wpn),pan(x));
13312 173 clk2=0;
13313 173 }
13314
13315 12693 Stunclk=0;
13316 12693 constant_walk(rate,homing,spw_none);
13317 12693 break;
13318
13319 case 1:
13320 case 2:
13321
2/2
✓ Branch 0 taken 3566 times.
✓ Branch 1 taken 41 times.
3607 if(--Stunclk<=0)
13322 {
13323 41 int32_t r=zc_oldrand();
13324
13325
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 17 times.
41 if(r&1)
13326 {
13327 17 y=96;
13328
13329
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 11 times.
17 if(r&2)
13330 6 x=160;
13331 else
13332 11 x=48;
13333
13334
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 8 times.
17 if(tooclose(x,y,48))
13335 8 x=208-x;
13336
13337 17 std::tie(x, y) = translate_screen_coordinates_to_world(screen_spawned, x, y);
13338 17 }
13339
13340 41 loadpalset(csBOSS,pSprite(d->bosspal));
13341 41 misc=0;
13342 41 }
13343
13344 3607 break;
13345
13346 case 3:
13347 {
13348
2/2
✓ Branch 0 taken 972 times.
✓ Branch 1 taken 12 times.
984 if(hclk>0)
13349 972 break;
13350
13351 12 misc=4;
13352 12 clk=0;
13353 12 hxofs=1000;
13354 12 loadpalset(9,pSprite(spPILE));
13355 12 music_stop();
13356 12 stop_sfx(WAV_ROAR);
13357
13358
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(deadsfx>0) sfx(deadsfx,pan(x));
13359
13360 12 sfx(WAV_GANON);
13361 //Ganon's dustpile; fall in sideview. -Z
13362 //item *dustpile = new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0);
13363 //dustpile->miscellaneous[31] = eeGANON;
13364
6/12
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 12 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 12 times.
✗ Branch 11 not taken.
12 items.add(new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0));
13365 12 item *dustpile = NULL;
13366 //dustpile = (item *)items.spr(items.Count() - 1)->getUID();
13367 12 dustpile = (item *)items.spr(items.Count() - 1);
13368 12 dustpile->linked_parent = eeGANON; //was miscellaneous[31]
13369 12 break;
13370 }
13371
13372 case 4:
13373
2/2
✓ Branch 0 taken 948 times.
✓ Branch 1 taken 12 times.
960 if(clk>=80)
13374 {
13375 12 misc=5;
13376
13377 //game->lvlitems[dlevel]|=(1 << li_boss_killed);
13378
13379 12 sfx(WAV_CLEARED);
13380 //Add the big TF over the ashes!
13381
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 12 times.
36 for(word q = 0; q < items.Count(); q++)
13382 {
13383 24 item *ashes = (item*)items.spr(q);
13384
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 12 times.
24 if ( ashes->linked_parent == eeGANON && (ashes->pickup&ipDUMMY))
13385 {
13386 //Z_scripterrlog("Found correct dustpile!\n");
13387
4/8
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12 times.
✗ Branch 7 not taken.
12 items.add(new item(ashes->x,ashes->y,(zfix)0,iBigTri,ipBIGTRI,0));
13388 12 item *bigtriforce = NULL;
13389 12 bigtriforce = (item *)items.spr(items.Count() - 1);
13390 12 bigtriforce->linked_parent = eeGANON;
13391 12 }
13392 24 }
13393 12 }
13394
13395 960 break;
13396 10 case 5: return true;
13397 }
13398
13399 18244 return enemy::animate(index);
13400 18254 }
13401
13402
13403 964 int32_t eGanon::takehit(weapon *w, weapon* realweap)
13404 {
13405 //these are here to bypass compiler warnings about unused arguments
13406 964 int32_t wpnId = w->id;
13407 964 int32_t power = w->power;
13408 964 int32_t enemyHitWeapon = w->parentitem;
13409
13410
3/3
✓ Branch 0 taken 714 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 166 times.
964 switch(misc)
13411 {
13412 case 0:
13413
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 53 times.
84 if(wpnId!=wSword)
13414 31 return 0;
13415
13416 53 hp-=power;
13417
13418
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 12 times.
53 if(hp>0)
13419 {
13420 41 misc=1;
13421 41 Stunclk=64;
13422 41 }
13423 else
13424 {
13425 12 loadpalset(csBOSS,pSprite(spBROWN));
13426 12 misc=2;
13427 12 Stunclk=284;
13428 12 hp=guysbuf[id&0xFFF].hp; //16*game->get_hero_dmgmult();
13429 }
13430
13431 53 sfx(WAV_EHIT,pan(x));
13432
13433
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if(hitsfx>0) sfx(hitsfx,pan(x));
13434
13435 53 return 1;
13436
13437 case 2:
13438
4/6
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
166 if(wpnId!=wArrow || (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_arrow))<4)
13439 154 return 0;
13440
13441 12 misc=3;
13442 12 hclk=81;
13443 12 loadpalset(9,pSprite(spBROWN));
13444 12 return 1;
13445 }
13446
13447 714 return 0;
13448 964 }
13449
13450 20776 void eGanon::draw(BITMAP *dest)
13451 {
13452
6/6
✓ Branch 0 taken 3608 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 983 times.
✓ Branch 3 taken 2535 times.
✓ Branch 4 taken 12680 times.
✓ Branch 5 taken 960 times.
20776 switch(misc)
13453 {
13454 case 0:
13455
2/2
✓ Branch 0 taken 9511 times.
✓ Branch 1 taken 3169 times.
12680 if((clk&3)==3)
13456 3169 tile=(zc_oldrand()%5)*2+o_tile;
13457
13458
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12680 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12680 if ( (editorflags & ENEMY_FLAG1) && current_item_power(itype_amulet) >= 2 ) //ganon is visible to level 2 amulet
13459 {
13460
13461 if ( editorflags & ENEMY_FLAG16 ) //draw cloaked
13462 {
13463 int odraw = drawstyle;
13464 drawstyle = 2;
13465 drawblock(dest,15);
13466 drawstyle = odraw;
13467 }
13468 else
13469 {
13470 drawblock(dest,15);
13471 }
13472 break;
13473
13474 }
13475
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12680 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12680 else if ( (editorflags & ENEMY_FLAG2) && (game->item[dmisc13]) )
13476 {
13477 if ( editorflags & ENEMY_FLAG16 ) //draw cloaked
13478 {
13479 int odraw = drawstyle;
13480 drawstyle = 2;
13481 drawblock(dest,15);
13482 drawstyle = odraw;
13483 }
13484 else
13485 {
13486 drawblock(dest,15);
13487 }
13488 break;
13489 }
13490
1/2
✓ Branch 0 taken 12680 times.
✗ Branch 1 not taken.
12680 if(db!=999)
13491 12680 break;
13492 [[fallthrough]];
13493 case 2:
13494
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 983 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
983 if(Stunclk<64 && (Stunclk&1))
13495 break;
13496 [[fallthrough]];
13497 case -1:
13498 3518 tile=o_tile;
13499
13500 [[fallthrough]];
13501 case 1:
13502 case 3:
13503 7126 drawblock(dest,15);
13504 7126 break;
13505
13506 case 4:
13507 960 draw_guts(dest);
13508 960 draw_flash(dest);
13509 960 break;
13510 }
13511 20776 }
13512
13513 960 void eGanon::draw_guts(BITMAP *dest)
13514 {
13515
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 204 times.
960 int32_t c = zc_min(clk>>3,8);
13516 960 tile = clk<24 ? 74 : 75;
13517 960 overtile16(dest,tile,x+8-viewport.x,y+c+playing_field_offset-viewport.y,9,0);
13518 960 overtile16(dest,tile,x+8-viewport.x,y+16-c+playing_field_offset-viewport.y,9,0);
13519 960 overtile16(dest,tile,x+c-viewport.x,y+8+playing_field_offset-viewport.y,9,0);
13520 960 overtile16(dest,tile,x+16-c-viewport.x,y+8+playing_field_offset-viewport.y,9,0);
13521 960 overtile16(dest,tile,x+c-viewport.x,y+c+playing_field_offset-viewport.y,9,0);
13522 960 overtile16(dest,tile,x+16-c-viewport.x,y+c+playing_field_offset-viewport.y,9,0);
13523 960 overtile16(dest,tile,x+c-viewport.x,y+16-c+playing_field_offset-viewport.y,9,0);
13524 960 overtile16(dest,tile,x+16-c-viewport.x,y+16-c+playing_field_offset-viewport.y,9,0);
13525 960 }
13526
13527 960 void eGanon::draw_flash(BITMAP *dest)
13528 {
13529
13530 960 int32_t c = clk-(clk>>2);
13531 960 cs = (frame&3)+6;
13532 960 overtile16(dest,194,x+8-viewport.x,y+8-clk+playing_field_offset-viewport.y,cs,0);
13533 960 overtile16(dest,194,x+8-viewport.x,y+8+clk+playing_field_offset-viewport.y,cs,2);
13534 960 overtile16(dest,195,x+8-clk-viewport.x,y+8+playing_field_offset-viewport.y,cs,0);
13535 960 overtile16(dest,195,x+8+clk-viewport.x,y+8+playing_field_offset-viewport.y,cs,1);
13536 960 overtile16(dest,196,x+8-c-viewport.x,y+8-c+playing_field_offset-viewport.y,cs,0);
13537 960 overtile16(dest,196,x+8+c-viewport.x,y+8-c+playing_field_offset-viewport.y,cs,1);
13538 960 overtile16(dest,196,x+8-c-viewport.x,y+8+c+playing_field_offset-viewport.y,cs,2);
13539 960 overtile16(dest,196,x+8+c-viewport.x,y+8+c+playing_field_offset-viewport.y,cs,3);
13540 960 }
13541
13542 19 void getBigTri(mapscr* scr, int32_t id2)
13543 {
13544 /*
13545 *************************
13546 * BIG TRIFORCE SEQUENCE *
13547 *************************
13548 0 BIGTRI out, WHITE flash in
13549 4 WHITE flash out, PILE cset white
13550 8 WHITE in
13551 ...
13552 188 WHITE out
13553 191 PILE cset red
13554 200 top SHUTTER opens
13555 209 bottom SHUTTER opens
13556 */
13557 19 sfx(itemsbuf[id2].playsound);
13558 19 guys.clear();
13559
13560
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 15 times.
19 if(itemsbuf[id2].flags & item_gamedata)
13561 {
13562 4 game->lvlitems[dlevel]|=(1 << li_mcguffin);
13563 4 }
13564
13565
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
19 setmapflag(scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
13566
13567 19 draw_screen();
13568
13569
4/4
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 3648 times.
✓ Branch 2 taken 19 times.
✓ Branch 3 taken 3648 times.
3667 for(int32_t f=0; f<24*8 && !Quit; f++)
13570 {
13571
2/2
✓ Branch 0 taken 3629 times.
✓ Branch 1 taken 19 times.
3648 if(f==4)
13572 {
13573
2/2
✓ Branch 0 taken 285 times.
✓ Branch 1 taken 19 times.
304 for(int32_t i=1; i<16; i++)
13574 {
13575 285 RAMpal[CSET(9)+i]=_RGB(255,255,255);
13576 285 }
13577 19 }
13578
13579
2/2
✓ Branch 0 taken 3192 times.
✓ Branch 1 taken 456 times.
3648 if((f&7)==0)
13580 {
13581
2/2
✓ Branch 0 taken 1368 times.
✓ Branch 1 taken 456 times.
1824 for(int32_t cs=2; cs<5; cs++)
13582 {
13583
2/2
✓ Branch 0 taken 20520 times.
✓ Branch 1 taken 1368 times.
21888 for(int32_t i=1; i<16; i++)
13584 {
13585 20520 RAMpal[CSET(cs)+i]=_RGB(255,255,255);
13586 20520 }
13587 1368 }
13588
13589 456 refreshpal=true;
13590 456 }
13591
13592
2/2
✓ Branch 0 taken 3192 times.
✓ Branch 1 taken 456 times.
3648 if((f&7)==4)
13593 {
13594
1/2
✓ Branch 0 taken 456 times.
✗ Branch 1 not taken.
456 if(cur_screen<128) loadlvlpal(DMaps[cur_dmap].color);
13595 else loadlvlpal(0xB);
13596 456 }
13597
13598
2/2
✓ Branch 0 taken 3629 times.
✓ Branch 1 taken 19 times.
3648 if(f==191)
13599 {
13600 19 loadpalset(9,pSprite(spPILE));
13601 19 }
13602
13603 3648 advanceframe(true);
13604 3648 }
13605
13606 //play_DmapMusic();
13607 19 playLevelMusic();
13608
13609
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
19 if(itemsbuf[id2].flags & item_flag1 && cur_screen < 128)
13610 {
13611 6 Hero.dowarp(hero_scr, 1, 0); //side warp
13612 6 }
13613 19 }
13614
13615 //! No. I am not adding SIZEflags to Moldorm and Lanmola. -Z 12 Aug 2020
13616 618 eMoldorm::eMoldorm(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13617 618 {
13618
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 if( !(editorflags & ENEMY_FLAG5) )
13619 {
13620
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 position_relative_to_screen(x, y, 128, 48);
13621 618 }
13622 //else { x = X; y = Y; }
13623
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 dir=(zc_oldrand()&7)+8;
13624 618 superman=1;
13625 618 fading=fade_invisible;
13626 618 hxofs=1000;
13627 618 segcnt=clk;
13628 618 segid=Id|0x1000;
13629 618 clk=0;
13630
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 id=guys.Count();
13631
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 618 times.
✓ Branch 2 taken 618 times.
✗ Branch 3 not taken.
618 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
13632 618 tile=o_tile;
13633 618 hitdir = -1;
13634 618 stickclk = 0;
13635
13636 /*
13637 if (get_qr(qr_NEWENEMYTILES))
13638 {
13639 tile=nets+1220;
13640 }
13641 else
13642 {
13643 tile=57;
13644 }
13645 */
13646 618 }
13647
13648 244844 bool eMoldorm::animate(int32_t index)
13649 {
13650 244844 update_current_screen();
13651
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 244844 times.
244844 if(switch_hooked) return enemy::animate(index);
13652 244844 int32_t max_y = isdungeon(screen_spawned) ? 100 : 100+28; //warning: Ugly hack. -Z
13653
2/2
✓ Branch 0 taken 216369 times.
✓ Branch 1 taken 28475 times.
244844 if ( y > (max_y) )
13654 {
13655 28475 ++stickclk; //Keep Moldorm from pacinn the bottom row or leaving the screen via the bottom edge. -Z 8th Sept, 2019
13656 //Z_scripterrlog("Stickclk is %d\n", stickclk);
13657 28475 }
13658
2/2
✓ Branch 0 taken 244282 times.
✓ Branch 1 taken 562 times.
244844 if ( stickclk > 45 )
13659 {
13660 562 stickclk = 0;
13661 562 newdir_8_old(rate,homing,spw_floater); //chage dir to keep from getting stuck.
13662 562 }
13663
13664
13665
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 244844 times.
244844 if(clk==0)
13666 {
13667 244844 removearmos(x,y);
13668 244844 }
13669
13670
2/2
✓ Branch 0 taken 2451 times.
✓ Branch 1 taken 242393 times.
244844 if(clk2)
13671 {
13672
2/2
✓ Branch 0 taken 2322 times.
✓ Branch 1 taken 129 times.
2451 if(--clk2 == 0)
13673 {
13674
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(flags&guy_never_return)
13675 129 never_return(screen_spawned, index);
13676
13677
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
129 if(!dmisc2 || (editorflags & ENEMY_FLAG6))
13678 129 leave_item();
13679
13680 129 stop_bgsfx(index);
13681 129 return true;
13682 }
13683 2322 }
13684 else
13685 {
13686
1/2
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
242393 if(stunclk>0)
13687 stunclk=0;
13688 242393 constant_walk_8_old(rate,homing,spw_floater);
13689
13690
13691 242393 misc=dir;
13692
13693 // If any higher-numbered segments were killed, segcnt can be too high,
13694 // leading to a crash
13695
1/2
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
242393 if(index+segcnt>=guys.Count())
13696 segcnt=guys.Count()-index-1;
13697
13698
2/2
✓ Branch 0 taken 242393 times.
✓ Branch 1 taken 1122281 times.
1364674 for(int32_t i=index+1; i<index+segcnt+1; i++)
13699 {
13700 1122281 enemy* segment=((enemy*)guys.spr(i));
13701
13702 // More validation - if segcnt was wrong, this may not
13703 // actually be a Moldorm segment
13704
1/2
✓ Branch 0 taken 1122281 times.
✗ Branch 1 not taken.
1122281 if(segment->id!=segid)
13705 {
13706 segcnt=i-index-1;
13707 break;
13708 }
13709
13710
2/2
✓ Branch 0 taken 879612 times.
✓ Branch 1 taken 242669 times.
1122281 if(i==index+1)
13711 {
13712 242669 x=segment->x;
13713 242669 y=segment->y;
13714 242669 }
13715
13716 1122281 segment->o_tile=tile; //I refuse to fuck with adding scripttile to segmented enemies. -Z
13717 //Script your own blasted segmented bosses!! -Z
13718 1122281 segment->setParent(this);
13719
4/4
✓ Branch 0 taken 242393 times.
✓ Branch 1 taken 879888 times.
✓ Branch 2 taken 24660 times.
✓ Branch 3 taken 217733 times.
1122281 if((i==index+segcnt)&&(i!=index+1)) //tail
13720 {
13721 217733 segment->dummy_int[1]=2;
13722 217733 }
13723 else
13724 {
13725 904548 segment->dummy_int[1]=1;
13726 }
13727
13728
2/2
✓ Branch 0 taken 879612 times.
✓ Branch 1 taken 242669 times.
1122281 if(i==index+1) //head
13729 {
13730 242669 segment->dummy_int[1]=0;
13731 242669 }
13732
13733
2/2
✓ Branch 0 taken 1121265 times.
✓ Branch 1 taken 1016 times.
1122281 if(segment->hp <= 0)
13734 {
13735 1016 int32_t offset=1;
13736
13737
2/2
✓ Branch 0 taken 1016 times.
✓ Branch 1 taken 1480 times.
2496 for(int32_t j=i; j<index+segcnt; j++)
13738 {
13739 // Triple-check
13740
1/2
✓ Branch 0 taken 1480 times.
✗ Branch 1 not taken.
1480 if(((enemy*)guys.spr(j+1))->id!=segid)
13741 {
13742 segcnt=j-index+1; // Add 1 because of --segcnt below
13743 break;
13744 }
13745 1480 zc_swap(((enemy*)guys.spr(j))->hp,((enemy*)guys.spr(j+1))->hp);
13746 1480 zc_swap(((enemy*)guys.spr(j))->hclk,((enemy*)guys.spr(j+1))->hclk);
13747 1480 }
13748
13749 1016 segment->hclk=33;
13750 1016 --segcnt;
13751 1016 --i; // Recheck the same index in case multiple segments died at once
13752 1016 }
13753 1122281 }
13754
13755
2/2
✓ Branch 0 taken 129 times.
✓ Branch 1 taken 242264 times.
242393 if(segcnt==0)
13756 {
13757 129 clk2=19;
13758
13759 129 x=guys.spr(index+1)->x;
13760 129 y=guys.spr(index+1)->y;
13761 129 }
13762 }
13763
13764 244715 return false;
13765 244844 }
13766
13767 3150 esMoldorm::esMoldorm(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13768 3150 {
13769
1/2
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
3150 if( !(editorflags & ENEMY_FLAG5) )
13770 {
13771
1/2
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
3150 position_relative_to_screen(x, y, 128, 48);
13772 3150 }
13773
13774
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3150 times.
✓ Branch 2 taken 3150 times.
✗ Branch 3 not taken.
3150 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
13775 3150 hyofs=4;
13776 3150 hit_width=hit_height=8;
13777 3150 hxofs=1000;
13778 3150 mainguy=count_enemy=false;
13779 3150 parentclk = 0;
13780 3150 bgsfx=-1;
13781
2/4
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3150 times.
✗ Branch 3 not taken.
3150 flags&=~guy_never_return;
13782 //deadsfx = WAV_EDEAD;
13783 3150 isCore = false;
13784 3150 }
13785
13786 1138024 bool esMoldorm::animate(int32_t index)
13787 {
13788
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1138024 times.
1138024 if(switch_hooked) return enemy::animate(index);
13789 // Shouldn't be possible, but better to be sure
13790
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1138024 times.
1138024 if(index==0)
13791 dying=true;
13792
13793
2/2
✓ Branch 0 taken 15743 times.
✓ Branch 1 taken 1122281 times.
1138024 if(dying)
13794 {
13795
1/2
✓ Branch 0 taken 15743 times.
✗ Branch 1 not taken.
15743 if(!dmisc2)
13796 15743 item_set=0;
13797
13798 15743 return Dead(index);
13799 }
13800
13801
2/2
✓ Branch 0 taken 105077 times.
✓ Branch 1 taken 1017204 times.
1122281 if(clk>=0)
13802 {
13803 1017204 hxofs=4;
13804 1017204 step=((enemy*)guys.spr(index-1))->step;
13805
13806
2/2
✓ Branch 0 taken 70455 times.
✓ Branch 1 taken 946749 times.
1017204 if(parentclk == 0)
13807 {
13808 70455 misc=dir;
13809 70455 dir=((enemy*)guys.spr(index-1))->misc;
13810 //do alignment, as in parent's animation :-/ -DD
13811 70455 x.doFloor();
13812 70455 y.doFloor();
13813 70455 }
13814
13815
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1017204 times.
1017204 if(step)
13816 1017204 parentclk=(parentclk+1)%((int32_t)(8.0/step));
13817
13818
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1017204 times.
1017204 if(!watch)
13819 {
13820 1017204 sprite::move(step);
13821 1017204 }
13822 1017204 }
13823
13824 1122281 return enemy::animate(index);
13825 1138024 }
13826
13827 2683 int32_t esMoldorm::takehit(weapon *w, weapon* realweap)
13828 {
13829
2/2
✓ Branch 0 taken 2230 times.
✓ Branch 1 taken 453 times.
2683 if(enemy::takehit(w,realweap))
13830 2230 return (w->id==wSBomb) ? 1 : 2; // force it to wait a frame before checking sword attacks again
13831
13832 453 return 0;
13833 2683 }
13834
13835 1155313 void esMoldorm::draw(BITMAP *dest)
13836 {
13837 1155313 tile=o_tile;
13838 1155313 int32_t fdiv = frate/4;
13839
1/2
✓ Branch 0 taken 1155313 times.
✗ Branch 1 not taken.
1155313 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13840
13841
2/2
✓ Branch 0 taken 1043930 times.
✓ Branch 1 taken 111383 times.
1155313 int32_t f2=get_qr(qr_NEWENEMYTILES)?
13842 1155313 efrate:((clk>=(frate>>1))?1:0);
13843
13844
2/2
✓ Branch 0 taken 111383 times.
✓ Branch 1 taken 1043930 times.
1155313 if(get_qr(qr_NEWENEMYTILES))
13845 {
13846 1043930 tile+=dummy_int[1]*40;
13847
13848
2/2
✓ Branch 0 taken 102730 times.
✓ Branch 1 taken 941200 times.
1043930 if(dir<8)
13849 {
13850 102730 flip=0;
13851
1/2
✓ Branch 0 taken 102730 times.
✗ Branch 1 not taken.
102730 tile+=4*zc_max(dir, 0); // dir is -1 if trapped
13852
13853
1/2
✓ Branch 0 taken 102730 times.
✗ Branch 1 not taken.
102730 if(dir>3) // Skip to the next row for diagonals
13854 tile+=4;
13855 102730 }
13856 else
13857 {
13858
8/9
✓ Branch 0 taken 96530 times.
✓ Branch 1 taken 134534 times.
✓ Branch 2 taken 113426 times.
✓ Branch 3 taken 124800 times.
✓ Branch 4 taken 101314 times.
✓ Branch 5 taken 99043 times.
✓ Branch 6 taken 131794 times.
✓ Branch 7 taken 139759 times.
✗ Branch 8 not taken.
941200 switch(dir-8) //directions get screwed up after 8. *shrug*
13859 {
13860 case up: //u
13861 96530 flip=0;
13862 96530 break;
13863
13864 case l_up: //d
13865 134534 flip=0;
13866 134534 tile+=4;
13867 134534 break;
13868
13869 case l_down: //l
13870 113426 flip=0;
13871 113426 tile+=8;
13872 113426 break;
13873
13874 case left: //r
13875 124800 flip=0;
13876 124800 tile+=12;
13877 124800 break;
13878
13879 case r_down: //ul
13880 101314 flip=0;
13881 101314 tile+=20;
13882 101314 break;
13883
13884 case down: //ur
13885 99043 flip=0;
13886 99043 tile+=24;
13887 99043 break;
13888
13889 case r_up: //dl
13890 131794 flip=0;
13891 131794 tile+=28;
13892 131794 break;
13893
13894 case right: //dr
13895 139759 flip=0;
13896 139759 tile+=32;
13897 139759 break;
13898 }
13899 }
13900
13901 1043930 tile+=f2;
13902 1043930 }
13903
13904
2/2
✓ Branch 0 taken 106267 times.
✓ Branch 1 taken 1049046 times.
1155313 if(clk>=0)
13905 1049046 enemy::draw(dest);
13906 1155313 }
13907
13908 420 eLanmola::eLanmola(zfix X,zfix Y,int32_t Id,int32_t Clk) : eBaseLanmola(X,Y,Id,Clk)
13909 420 {
13910
1/2
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
420 if( !(editorflags & ENEMY_FLAG5) )
13911 {
13912
1/2
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
420 position_relative_to_screen(x, y, 64, 80);
13913 420 }
13914 //else { x = X; y = Y; }
13915 //byte legaldirs = 0;
13916 420 int32_t incr = 16;
13917 //int32_t possiiblepos = 0;
13918 //int32_t positions[8] = {0};
13919
13920 //Don't spawn in pits.
13921
5/8
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 420 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 420 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 315 times.
✓ Branch 7 taken 105 times.
420 if ( m_walkflag_simple(x, y) )
13922 {
13923
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
139 for ( ; incr < 240; incr += 16 )
13924 {
13925 //move if we spawn over a pit
13926 //check each direction
13927
7/12
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 139 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 139 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 139 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 139 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 4 times.
✓ Branch 11 taken 135 times.
139 if ( !m_walkflag_simple(x-incr, y) ) //legaldirs |= 0x1; //left
13928 {
13929
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 x-=incr; break;
13930 }
13931
7/12
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 135 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 135 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 135 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 135 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 39 times.
✓ Branch 11 taken 96 times.
135 else if ( !m_walkflag_simple(x+incr, y) ) //legaldirs |= 0x2; //right
13932 {
13933
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
39 x+=incr; break;
13934 }
13935
9/16
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 96 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 96 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 96 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 96 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 96 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 32 times.
✓ Branch 15 taken 64 times.
96 else if ( !m_walkflag_simple(x-incr, y-incr) ) //legaldirs |= 0x4; //left-up
13936 {
13937
2/4
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
32 x-=incr; y-=incr; break;
13938 }
13939
9/16
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 64 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 64 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 64 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 64 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 64 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 64 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 4 times.
✓ Branch 15 taken 60 times.
64 else if ( !m_walkflag_simple(x+incr, y-incr) ) //legaldirs |= 0x8; //right-up
13940 {
13941
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 x+=incr; y-=incr; break;
13942 }
13943
6/12
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 60 times.
60 else if ( !m_walkflag_simple(x, y-incr) ) // legaldirs |= 0x10; //up
13944 {
13945 y -= incr; break;
13946 }
13947
6/12
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 60 times.
60 else if ( !m_walkflag_simple(x, y+incr) ) //legaldirs |= 0x20; //down
13948 {
13949 y+=incr; break;
13950 }
13951
9/16
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 60 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 60 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 26 times.
✓ Branch 15 taken 34 times.
60 else if ( !m_walkflag_simple(x-incr, y+incr) ) //legaldirs |= 0x40; //left-down
13952 {
13953
2/4
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26 times.
✗ Branch 3 not taken.
26 x-=incr; y+=incr; break;
13954 }
13955
8/16
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 34 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 34 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 34 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 34 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 34 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 34 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 34 times.
34 else if ( !m_walkflag_simple(x+incr, y+incr) ) //legaldirs |= 0x80; //right-down
13956 {
13957 x+=incr; y+=incr; break;
13958 }
13959 34 else continue;
13960
13961 }
13962
13963 105 }
13964
13965 420 dir=up;
13966 420 superman=1;
13967 420 fading=fade_invisible;
13968 420 hxofs=1000;
13969 420 segcnt=clk;
13970 420 clk=0;
13971 //set up move history
13972
2/2
✓ Branch 0 taken 420 times.
✓ Branch 1 taken 3060 times.
3480 for(int32_t i=0; i <= (1<<dmisc2); i++)
13973
3/6
✓ Branch 0 taken 3060 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3060 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3060 times.
✗ Branch 5 not taken.
3060 prevState.push_back(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix,zfix>(x,y), dir));
13974 420 }
13975
13976 236907 bool eLanmola::animate(int32_t index)
13977 {
13978
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 236907 times.
236907 if(switch_hooked) return enemy::animate(index);
13979
2/2
✓ Branch 0 taken 196711 times.
✓ Branch 1 taken 40196 times.
236907 if(clk==0)
13980 {
13981 40196 removearmos(x,y);
13982 40196 }
13983
13984
2/2
✓ Branch 0 taken 3591 times.
✓ Branch 1 taken 233316 times.
236907 if(clk2)
13985 {
13986
2/2
✓ Branch 0 taken 3402 times.
✓ Branch 1 taken 189 times.
3591 if(--clk2 == 0)
13987 {
13988
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 103 times.
189 if(!dmisc3) //This checks if "segments drop items" isn't true, because if they don't drop items, then only killing the whole thing drops an item.
13989 86 leave_item();
13990
13991 189 stop_bgsfx(index);
13992 189 return true;
13993 }
13994
13995 3402 return false;
13996 }
13997
13998
13999 //this animation style plays ALL KINDS of havoc on the Lanmola segments, since it causes
14000 //the direction AND x,y position of the lanmola to vary in uncertain ways.
14001 //I've added a complete movement history to this enemy to compensate -DD
14002 233316 constant_walk(rate,homing,spw_none);
14003 233316 prevState.pop_front();
14004 233316 prevState.push_front(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix, zfix>(x,y), dir));
14005
14006 // This could cause a crash with Moldorms. I didn't see the same problem
14007 // with Lanmolas, but it looks like it ought to be possible, so here's
14008 // the same solution. - Saf
14009
1/2
✓ Branch 0 taken 233316 times.
✗ Branch 1 not taken.
233316 if(index+segcnt>=guys.Count())
14010 segcnt=guys.Count()-index-1;
14011
14012
2/2
✓ Branch 0 taken 233316 times.
✓ Branch 1 taken 966396 times.
1199712 for(int32_t i=index+1; i<index+segcnt+1; i++)
14013 {
14014 966396 enemy* segment=((enemy*)guys.spr(i));
14015
14016 // More validation in case segcnt is wrong
14017
1/2
✓ Branch 0 taken 966396 times.
✗ Branch 1 not taken.
966396 if((segment->id&0xFFF)!=(id&0xFFF))
14018 {
14019 segcnt=i-index-1;
14020 break;
14021 }
14022
14023 966396 segment->o_tile=o_tile;
14024 966396 segment->setParent(this);
14025
4/4
✓ Branch 0 taken 233316 times.
✓ Branch 1 taken 733080 times.
✓ Branch 2 taken 37616 times.
✓ Branch 3 taken 195700 times.
966396 if((i==index+segcnt)&&(i!=index+1))
14026 {
14027 195700 segment->dummy_int[1]=1; //tail
14028 195700 }
14029 else
14030 {
14031 770696 segment->dummy_int[1]=0;
14032 }
14033
14034
2/2
✓ Branch 0 taken 965227 times.
✓ Branch 1 taken 1169 times.
966396 if(segment->hp <= 0)
14035 {
14036
2/2
✓ Branch 0 taken 1169 times.
✓ Branch 1 taken 1961 times.
3130 for(int32_t j=i; j<index+segcnt; j++)
14037 {
14038 // Triple-check
14039
1/2
✓ Branch 0 taken 1961 times.
✗ Branch 1 not taken.
1961 if((((enemy*)guys.spr(j+1))->id&0xFFF)!=(id&0xFFF))
14040 {
14041 segcnt=j-index+1; // Add 1 because of --segcnt below
14042 break;
14043 }
14044 1961 zc_swap(((enemy*)guys.spr(j))->hp,((enemy*)guys.spr(j+1))->hp);
14045 1961 zc_swap(((enemy*)guys.spr(j))->hclk,((enemy*)guys.spr(j+1))->hclk);
14046 1961 }
14047
14048 1169 ((enemy*)guys.spr(i))->hclk=33;
14049 1169 --segcnt;
14050 1169 --i; // Recheck the same index in case multiple segments died at once
14051 1169 }
14052 966396 }
14053
14054
2/2
✓ Branch 0 taken 233127 times.
✓ Branch 1 taken 189 times.
233316 if(segcnt==0)
14055 {
14056 189 clk2=19;
14057 189 x=guys.spr(index+1)->x;
14058 189 y=guys.spr(index+1)->y;
14059 189 setmapflag(get_scr(screen_spawned), mTMPNORET);
14060 189 }
14061
14062 //this enemy is invincible.. BUT scripts don't know that, and can "kill" it by setting the hp negative.
14063 //which is... disastrous.
14064 233316 hp = 1;
14065 233316 return enemy::animate(index);
14066 236907 }
14067
14068 2267 esLanmola::esLanmola(zfix X,zfix Y,int32_t Id,int32_t Clk) : eBaseLanmola(X,Y,Id,Clk)
14069 2267 {
14070
1/2
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
2267 if( !(editorflags & ENEMY_FLAG5) )
14071 {
14072
1/2
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
2267 position_relative_to_screen(x, y, 64, 80);
14073 2267 }
14074 2267 int32_t incr = 16;
14075 //Don't spawn in pits.
14076
5/8
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2267 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2267 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1742 times.
✓ Branch 7 taken 525 times.
2267 if ( m_walkflag_simple(x, y) )
14077 {
14078
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 695 times.
695 for ( ; incr < 240; incr += 16 )
14079 {
14080 //move if we spawn over a pit
14081 //check each direction
14082
7/12
✓ Branch 0 taken 695 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 695 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 695 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 695 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 695 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 20 times.
✓ Branch 11 taken 675 times.
695 if ( !m_walkflag_simple(x-incr, y) ) //legaldirs |= 0x1; //left
14083 {
14084
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 x-=incr; break;
14085 }
14086
7/12
✓ Branch 0 taken 675 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 675 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 675 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 675 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 675 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 195 times.
✓ Branch 11 taken 480 times.
675 else if ( !m_walkflag_simple(x+incr, y) ) //legaldirs |= 0x2; //right
14087 {
14088
1/2
✓ Branch 0 taken 195 times.
✗ Branch 1 not taken.
195 x+=incr; break;
14089 }
14090
9/16
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 480 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 480 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 480 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 480 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 480 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 480 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 160 times.
✓ Branch 15 taken 320 times.
480 else if ( !m_walkflag_simple(x-incr, y-incr) ) //legaldirs |= 0x4; //left-up
14091 {
14092
2/4
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 160 times.
✗ Branch 3 not taken.
160 x-=incr; y-=incr; break;
14093 }
14094
9/16
✓ Branch 0 taken 320 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 320 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 320 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 320 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 320 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 320 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 320 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 20 times.
✓ Branch 15 taken 300 times.
320 else if ( !m_walkflag_simple(x+incr, y-incr) ) //legaldirs |= 0x8; //right-up
14095 {
14096
2/4
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
20 x+=incr; y-=incr; break;
14097 }
14098
6/12
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 300 times.
300 else if ( !m_walkflag_simple(x, y-incr) ) // legaldirs |= 0x10; //up
14099 {
14100 y -= incr; break;
14101 }
14102
6/12
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 300 times.
300 else if ( !m_walkflag_simple(x, y+incr) ) //legaldirs |= 0x20; //down
14103 {
14104 y+=incr; break;
14105 }
14106
9/16
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 300 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 300 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 130 times.
✓ Branch 15 taken 170 times.
300 else if ( !m_walkflag_simple(x-incr, y+incr) ) //legaldirs |= 0x40; //left-down
14107 {
14108
2/4
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 130 times.
✗ Branch 3 not taken.
130 x-=incr; y+=incr; break;
14109 }
14110
8/16
✓ Branch 0 taken 170 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 170 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 170 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 170 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 170 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 170 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 170 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 170 times.
170 else if ( !m_walkflag_simple(x+incr, y+incr) ) //legaldirs |= 0x80; //right-down
14111 {
14112 x+=incr; y+=incr; break;
14113 }
14114 170 else continue;
14115
14116 }
14117
14118 525 }
14119
14120 2267 hxofs=1000;
14121 2267 hit_width=8;
14122 2267 mainguy=false;
14123 2267 count_enemy=(id<0x2000)?true:false;
14124
14125 //set up move history
14126
2/2
✓ Branch 0 taken 2267 times.
✓ Branch 1 taken 16763 times.
19030 for(int32_t i=0; i <= (1<<dmisc2); i++)
14127
3/6
✓ Branch 0 taken 16763 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16763 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16763 times.
✗ Branch 5 not taken.
16763 prevState.push_back(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix,zfix>(x,y), dir));
14128
14129 2267 bgsfx = -1;
14130 2267 isCore = false;
14131
2/4
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2267 times.
✗ Branch 3 not taken.
2267 flags&=~guy_never_return;
14132 2267 }
14133
14134 985563 bool esLanmola::animate(int32_t index)
14135 {
14136
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 985563 times.
985563 if(switch_hooked) return enemy::animate(index);
14137 // Shouldn't be possible, but who knows
14138
2/2
✓ Branch 0 taken 985545 times.
✓ Branch 1 taken 18 times.
985563 if(index==0)
14139 18 dying=true;
14140
14141
2/2
✓ Branch 0 taken 19167 times.
✓ Branch 1 taken 966396 times.
985563 if(dying)
14142 {
14143 19167 xofs=0;
14144
14145
2/2
✓ Branch 0 taken 9861 times.
✓ Branch 1 taken 9306 times.
19167 if(!dmisc3)
14146 9306 item_set=0;
14147
14148 19167 return Dead(index);
14149 }
14150
14151
2/2
✓ Branch 0 taken 35946 times.
✓ Branch 1 taken 930450 times.
966396 if(clk>=0)
14152 {
14153 930450 hxofs=4;
14154
14155
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 930450 times.
930450 if(!watch)
14156 {
14157 930450 std::pair<std::pair<zfix, zfix>, int32_t> newstate = ((eBaseLanmola*)guys.spr(index-1))->prevState.front();
14158 930450 prevState.pop_front();
14159 930450 prevState.push_back(newstate);
14160 930450 x = newstate.first.first;
14161 930450 y = newstate.first.second;
14162 930450 dir = newstate.second;
14163 930450 }
14164 930450 }
14165
14166 966396 return enemy::animate(index);
14167 985563 }
14168
14169 2655 int32_t esLanmola::takehit(weapon *w, weapon* realweap)
14170 {
14171
2/2
✓ Branch 0 taken 2065 times.
✓ Branch 1 taken 590 times.
2655 if(enemy::takehit(w,realweap))
14172 2065 return (w->id==wSBomb) ? 1 : 2; // force it to wait a frame before checking sword attacks again
14173
14174 590 return 0;
14175 2655 }
14176
14177 990931 void esLanmola::draw(BITMAP *dest)
14178 {
14179 990931 tile=o_tile;
14180 990931 int32_t fdiv = frate/4;
14181
1/2
✓ Branch 0 taken 990931 times.
✗ Branch 1 not taken.
990931 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14182
14183
2/2
✓ Branch 0 taken 628932 times.
✓ Branch 1 taken 361999 times.
990931 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14184 990931 efrate:((clk>=(frate>>1))?1:0);
14185
14186
2/2
✓ Branch 0 taken 628932 times.
✓ Branch 1 taken 361999 times.
990931 if(get_qr(qr_NEWENEMYTILES))
14187 {
14188
2/2
✓ Branch 0 taken 147165 times.
✓ Branch 1 taken 481767 times.
628932 if(id>=0x2000)
14189 {
14190 481767 tile+=20;
14191
14192
2/2
✓ Branch 0 taken 353025 times.
✓ Branch 1 taken 128742 times.
481767 if(dummy_int[1]==1)
14193 {
14194 128742 tile+=20;
14195 128742 }
14196 481767 }
14197
14198
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 141419 times.
✓ Branch 2 taken 140994 times.
✓ Branch 3 taken 159500 times.
✓ Branch 4 taken 187019 times.
628932 switch(dir)
14199 {
14200 case up:
14201 141419 flip=0;
14202 141419 break;
14203
14204 case down:
14205 140994 flip=0;
14206 140994 tile+=4;
14207 140994 break;
14208
14209 case left:
14210 159500 flip=0;
14211 159500 tile+=8;
14212 159500 break;
14213
14214 case right:
14215 187019 flip=0;
14216 187019 tile+=12;
14217 187019 break;
14218 }
14219
14220 628932 tile+=f2;
14221 628932 }
14222 else
14223 {
14224
2/2
✓ Branch 0 taken 90543 times.
✓ Branch 1 taken 271456 times.
361999 if(id>=0x2000)
14225 {
14226 271456 tile+=1;
14227 271456 }
14228 }
14229
14230
2/2
✓ Branch 0 taken 37038 times.
✓ Branch 1 taken 953893 times.
990931 if(clk>=0)
14231 953893 enemy::draw(dest);
14232 990931 }
14233
14234 150 eManhandla::eManhandla(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,0)
14235 150 {
14236 //these are here to bypass compiler warnings about unused arguments
14237 150 Clk=Clk;
14238 150 superman=1;
14239
1/2
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
150 dir=(zc_oldrand()&7)+8;
14240 150 armcnt=dmisc2?8:4;//((id==eMANHAN)?4:8);
14241
14242
2/2
✓ Branch 0 taken 692 times.
✓ Branch 1 taken 150 times.
842 for(int32_t i=0; i<armcnt; i++)
14243 692 arm[i]=i;
14244
14245 150 fading=fade_blue_poof;
14246 //nets+4680;
14247 150 adjusted=false;
14248
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 150 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
150 if (SIZEflags != 0) init_size_flags();;
14249 150 }
14250
14251 66494 bool eManhandla::animate(int32_t index)
14252 {
14253
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66494 times.
66494 if(switch_hooked) return enemy::animate(index);
14254
2/2
✓ Branch 0 taken 1382 times.
✓ Branch 1 taken 65112 times.
66494 if(dying)
14255 1382 return Dead(index);
14256
14257
2/2
✓ Branch 0 taken 62641 times.
✓ Branch 1 taken 2471 times.
65112 if(clk==0)
14258 {
14259 2471 removearmos(x,y);
14260 2471 }
14261
14262
14263 // check arm status, move dead ones to end of group
14264
2/2
✓ Branch 0 taken 193618 times.
✓ Branch 1 taken 65112 times.
258730 for(int32_t i=0; i<armcnt; i++)
14265 {
14266 193618 enemy* cur_arm = ((enemy*)guys.spr(index+i+1));
14267
3/4
✓ Branch 0 taken 193618 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 424 times.
✓ Branch 3 taken 193194 times.
193618 if(!cur_arm || cur_arm->dying)
14268 {
14269
2/2
✓ Branch 0 taken 552 times.
✓ Branch 1 taken 424 times.
976 for(int32_t j=i; j<armcnt-1; j++)
14270 {
14271 552 zc_swap(arm[j],arm[j+1]);
14272 552 guys.swap(index+j+1,index+j+2);
14273 552 }
14274
2/2
✓ Branch 0 taken 337 times.
✓ Branch 1 taken 87 times.
424 if((editorflags & ENEMY_FLAG6)) //They only did this in 2.10
14275 {
14276 87 leave_item();
14277 87 }
14278 424 --armcnt;
14279 424 --i;
14280 424 continue;
14281 }
14282
2/2
✓ Branch 0 taken 192502 times.
✓ Branch 1 taken 692 times.
193194 if(!adjusted)
14283 {
14284
2/2
✓ Branch 0 taken 508 times.
✓ Branch 1 taken 184 times.
692 if(!dmisc2)
14285 {
14286 508 cur_arm->o_tile=o_tile+40;
14287 508 cur_arm->setParent(this);
14288 508 }
14289 else
14290 {
14291 184 cur_arm->o_tile=o_tile+160;
14292 184 cur_arm->setParent(this);
14293 }
14294 692 }
14295 193194 }
14296
14297 65112 adjusted=true;
14298
14299 // move or die
14300
2/2
✓ Branch 0 taken 65029 times.
✓ Branch 1 taken 83 times.
65112 if(armcnt==0)
14301 83 hp=0;
14302 else
14303 {
14304 // Speed starts at 0.5, and increases by 0.5 for each head lost. Max speed is 4.5.
14305
2/2
✓ Branch 0 taken 53584 times.
✓ Branch 1 taken 11445 times.
65029 step = ((dmisc2 ? 8_zf : 4_zf) - armcnt) * 0.5 + (dstep / 100);
14306
1/2
✓ Branch 0 taken 65029 times.
✗ Branch 1 not taken.
65029 if (step > 4.5_zf) step = 4.5_zf;
14307 65029 int32_t dx1=0, dy1=-8, dx2=15, dy2=15;
14308
14309
2/2
✓ Branch 0 taken 53584 times.
✓ Branch 1 taken 11445 times.
65029 if(!dmisc2)
14310 {
14311
2/2
✓ Branch 0 taken 151019 times.
✓ Branch 1 taken 53584 times.
204603 for(int32_t i=0; i<armcnt; i++)
14312 {
14313
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 38579 times.
✓ Branch 2 taken 36328 times.
✓ Branch 3 taken 36250 times.
✓ Branch 4 taken 39862 times.
151019 switch(arm[i])
14314 {
14315 case 0:
14316 38579 dy1=-24;
14317 38579 break;
14318
14319 case 1:
14320 36328 dy2=31;
14321 36328 break;
14322
14323 case 2:
14324 36250 dx1=-16;
14325 36250 break;
14326
14327 case 3:
14328 39862 dx2=31;
14329 39862 break;
14330 }
14331 151019 }
14332 53584 }
14333 else
14334 {
14335 11445 dx1=-8, dy1=-16, dx2=23, dy2=23;
14336
14337
2/2
✓ Branch 0 taken 42175 times.
✓ Branch 1 taken 11445 times.
53620 for(int32_t i=0; i<armcnt; i++)
14338 {
14339
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 12012 times.
✓ Branch 2 taken 7730 times.
✓ Branch 3 taken 9837 times.
✓ Branch 4 taken 12596 times.
42175 switch(arm[i]&3)
14340 {
14341 case 0:
14342 12012 dy1=-32;
14343 12012 break;
14344
14345 case 1:
14346 7730 dy2=39;
14347 7730 break;
14348
14349 case 2:
14350 9837 dx1=-24;
14351 9837 break;
14352
14353 case 3:
14354 12596 dx2=39;
14355 12596 break;
14356 }
14357 42175 }
14358 }
14359
14360 65029 variable_walk_8(rate,homing,hrate,spw_floater,dx1,dy1,dx2,dy2);
14361
14362
2/2
✓ Branch 0 taken 193194 times.
✓ Branch 1 taken 65029 times.
258223 for(int32_t i=0; i<armcnt; i++)
14363 {
14364 193194 zfix dx=(zfix)0,dy=(zfix)0;
14365
14366
2/2
✓ Branch 0 taken 151019 times.
✓ Branch 1 taken 42175 times.
193194 if(!dmisc2)
14367 {
14368
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 38579 times.
✓ Branch 2 taken 36328 times.
✓ Branch 3 taken 36250 times.
✓ Branch 4 taken 39862 times.
151019 switch(arm[i])
14369 {
14370 case 0:
14371 38579 dy=-16;
14372 38579 break;
14373
14374 case 1:
14375 36328 dy=16;
14376 36328 break;
14377
14378 case 2:
14379 36250 dx=-16;
14380 36250 break;
14381
14382 case 3:
14383 39862 dx=16;
14384 39862 break;
14385 }
14386 151019 }
14387 else
14388 {
14389
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 5447 times.
✓ Branch 2 taken 3986 times.
✓ Branch 3 taken 4163 times.
✓ Branch 4 taken 6774 times.
✓ Branch 5 taken 6565 times.
✓ Branch 6 taken 3744 times.
✓ Branch 7 taken 5674 times.
✓ Branch 8 taken 5822 times.
42175 switch(arm[i])
14390 {
14391 case 0:
14392 5447 dy=-24;
14393 5447 dx=-8;
14394 5447 break;
14395
14396 case 1:
14397 3986 dy=24;
14398 3986 dx=8;
14399 3986 break;
14400
14401 case 2:
14402 4163 dx=-24;
14403 4163 dy=8;
14404 4163 break;
14405
14406 case 3:
14407 6774 dx=24;
14408 6774 dy=-8;
14409 6774 break;
14410
14411 case 4:
14412 6565 dy=-24;
14413 6565 dx=8;
14414 6565 break;
14415
14416 case 5:
14417 3744 dy=24;
14418 3744 dx=-8;
14419 3744 break;
14420
14421 case 6:
14422 5674 dx=-24;
14423 5674 dy=-8;
14424 5674 break;
14425
14426 case 7:
14427 5822 dx=24;
14428 5822 dy=8;
14429 5822 break;
14430 }
14431 }
14432
14433 193194 guys.spr(index+i+1)->x = x+dx;
14434 193194 guys.spr(index+i+1)->y = y+dy;
14435 193194 }
14436 }
14437
14438 65112 return enemy::animate(index);
14439 66494 }
14440
14441
14442 1751 int32_t eManhandla::takehit(weapon *w, weapon* realweap)
14443 {
14444 1751 int32_t wpnId = w->id;
14445
14446
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1751 times.
1751 if(dying)
14447 return 0;
14448
14449
3/4
✓ Branch 0 taken 923 times.
✓ Branch 1 taken 786 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 42 times.
1751 switch(wpnId)
14450 {
14451 case wBomb:
14452 case wSBomb:
14453 case wSword:
14454 case wHammer:
14455 case wWand:
14456
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 786 times.
786 if (get_qr(qr_MANHANDLA_BLOCK_SFX)) sfx(WAV_EHIT,pan(x));
14457
14458 case wLitBomb:
14459 case wLitSBomb:
14460 case wBait:
14461 case wWhistle:
14462 case wFire:
14463 case wWind:
14464 case wSSparkle:
14465 case wFSparkle:
14466 case wPhantom:
14467 1709 return 0;
14468
14469 case wHookshot:
14470 case wBrang:
14471 sfx(WAV_CHINK,pan(x));
14472 break;
14473
14474 default:
14475
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if (get_qr(qr_MANHANDLA_BLOCK_SFX)) sfx(WAV_EHIT,pan(x));
14476 else sfx(WAV_CHINK,pan(x));
14477
14478 42 }
14479
14480 42 return 1;
14481 1751 }
14482
14483 66490 void eManhandla::draw(BITMAP *dest)
14484 {
14485 66490 tile=o_tile;
14486 66490 int32_t fdiv = frate/4;
14487
1/2
✓ Branch 0 taken 66490 times.
✗ Branch 1 not taken.
66490 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14488
14489
2/2
✓ Branch 0 taken 48802 times.
✓ Branch 1 taken 17688 times.
66490 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14490 66490 efrate:((clk>=(frate>>1))?1:0);
14491
14492
2/2
✓ Branch 0 taken 48802 times.
✓ Branch 1 taken 17688 times.
66490 if(get_qr(qr_NEWENEMYTILES))
14493 {
14494
2/2
✓ Branch 0 taken 11308 times.
✓ Branch 1 taken 37494 times.
48802 if(!dmisc2)
14495 {
14496
8/9
✓ Branch 0 taken 4771 times.
✓ Branch 1 taken 4640 times.
✓ Branch 2 taken 4995 times.
✓ Branch 3 taken 5574 times.
✓ Branch 4 taken 3793 times.
✓ Branch 5 taken 3930 times.
✓ Branch 6 taken 3908 times.
✓ Branch 7 taken 5883 times.
✗ Branch 8 not taken.
37494 switch(dir-8) //directions get screwed up after 8. *shrug*
14497 {
14498 case up: //u
14499 4771 flip=0;
14500 4771 break;
14501
14502 case l_up: //d
14503 4640 flip=0;
14504 4640 tile+=4;
14505 4640 break;
14506
14507 case l_down: //l
14508 4995 flip=0;
14509 4995 tile+=8;
14510 4995 break;
14511
14512 case left: //r
14513 5574 flip=0;
14514 5574 tile+=12;
14515 5574 break;
14516
14517 case r_down: //ul
14518 3793 flip=0;
14519 3793 tile+=20;
14520 3793 break;
14521
14522 case down: //ur
14523 3930 flip=0;
14524 3930 tile+=24;
14525 3930 break;
14526
14527 case r_up: //dl
14528 3908 flip=0;
14529 3908 tile+=28;
14530 3908 break;
14531
14532 case right: //dr
14533 5883 flip=0;
14534 5883 tile+=32;
14535 5883 break;
14536 }
14537
14538 37494 tile+=f2;
14539 37494 enemy::draw(dest);
14540 37494 } //manhandla 2, big body
14541 else
14542 {
14543
14544
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 1277 times.
✓ Branch 2 taken 1360 times.
✓ Branch 3 taken 2242 times.
✓ Branch 4 taken 1789 times.
✓ Branch 5 taken 1345 times.
✓ Branch 6 taken 805 times.
✓ Branch 7 taken 948 times.
✓ Branch 8 taken 1542 times.
11308 switch(dir-8) //directions get screwed up after 8. *shrug*
14545 {
14546 case up: //u
14547 1277 flip=0;
14548 1277 break;
14549
14550 case l_up: //d
14551 1360 flip=0;
14552 1360 tile+=8;
14553 1360 break;
14554
14555 case l_down: //l
14556 2242 flip=0;
14557 2242 tile+=40;
14558 2242 break;
14559
14560 case left: //r
14561 1789 flip=0;
14562 1789 tile+=48;
14563 1789 break;
14564
14565 case r_down: //ul
14566 1345 flip=0;
14567 1345 tile+=80;
14568 1345 break;
14569
14570 case down: //ur
14571 805 flip=0;
14572 805 tile+=88;
14573 805 break;
14574
14575 case r_up: //dl
14576 948 flip=0;
14577 948 tile+=120;
14578 948 break;
14579
14580 case right: //dr
14581 1542 flip=0;
14582 1542 tile+=128;
14583 1542 break;
14584 }
14585
14586 11308 tile+=(f2*2);
14587 11308 xofs-=8;
14588 11308 yofs-=8;
14589 11308 drawblock(dest,15);
14590 11308 xofs+=8;
14591 11308 yofs+=8;
14592 }
14593 48802 }
14594 else
14595 {
14596
2/2
✓ Branch 0 taken 515 times.
✓ Branch 1 taken 17173 times.
17688 if(!dmisc2)
14597 {
14598 17173 enemy::draw(dest);
14599 17173 }
14600 else
14601 {
14602 515 xofs-=8;
14603 515 yofs-=8;
14604 515 enemy::draw(dest);
14605 515 xofs+=16;
14606 515 enemy::draw(dest);
14607 515 yofs+=16;
14608 515 enemy::draw(dest);
14609 515 xofs-=16;
14610 515 enemy::draw(dest);
14611 515 xofs+=8;
14612 515 yofs-=8;
14613 }
14614 }
14615 66490 }
14616
14617 692 esManhandla::esManhandla(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
14618 692 {
14619 692 id=misc=clk;
14620 692 dir = clk & 3;
14621 692 clk=0;
14622 692 mainguy=count_enemy=false;
14623 692 dummy_bool[0]=false;
14624 692 item_set=0;
14625 692 bgsfx=-1;
14626 692 deadsfx = WAV_EDEAD;
14627
2/4
✓ Branch 0 taken 692 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 692 times.
✗ Branch 3 not taken.
692 flags &= (~guy_never_return);
14628 692 isCore = false;
14629
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 692 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
692 if (SIZEflags != 0) init_size_flags();;
14630 692 }
14631
14632 200202 bool esManhandla::animate(int32_t index)
14633 {
14634
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200202 times.
200202 if(switch_hooked) return enemy::animate(index);
14635
2/2
✓ Branch 0 taken 7008 times.
✓ Branch 1 taken 193194 times.
200202 if(dying)
14636 7008 return Dead(index);
14637
14638
2/2
✓ Branch 0 taken 12404 times.
✓ Branch 1 taken 180790 times.
193194 if(clk==0)
14639 {
14640 12404 removearmos(x,y);
14641 12404 }
14642
14643
2/2
✓ Branch 0 taken 165298 times.
✓ Branch 1 taken 27896 times.
193194 if(--clk2<=0)
14644 {
14645 27896 clk2=unsigned(zc_oldrand())%5+5;
14646 27896 clk3^=1;
14647 27896 }
14648
14649
2/2
✓ Branch 0 taken 1491 times.
✓ Branch 1 taken 191703 times.
193194 if(!(zc_oldrand()&127))
14650 {
14651 1491 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
14652 1491 sfx(wpnsfx(wpn),pan(x));
14653 1491 }
14654
14655 193194 return enemy::animate(index);
14656 200202 }
14657
14658 200186 void esManhandla::draw(BITMAP *dest)
14659 {
14660 200186 tile=o_tile;
14661 200186 int32_t fdiv = frate/4;
14662
1/2
✓ Branch 0 taken 200186 times.
✗ Branch 1 not taken.
200186 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14663
2/2
✓ Branch 0 taken 158716 times.
✓ Branch 1 taken 41470 times.
200186 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14664 200186 efrate:((clk>=(frate>>1))?1:0);
14665
14666
2/2
✓ Branch 0 taken 158716 times.
✓ Branch 1 taken 41470 times.
200186 if(get_qr(qr_NEWENEMYTILES))
14667 {
14668
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 39945 times.
✓ Branch 2 taken 36845 times.
✓ Branch 3 taken 39966 times.
✓ Branch 4 taken 41960 times.
158716 switch(misc&3)
14669 {
14670 case up:
14671 39945 break;
14672
14673 case down:
14674 36845 tile+=4;
14675 36845 break;
14676
14677 case left:
14678 39966 tile+=8;
14679 39966 break;
14680
14681 case right:
14682 41960 tile+=12;
14683 41960 break;
14684 }
14685
14686 158716 tile+=f2;
14687 158716 }
14688 else
14689 {
14690
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 12394 times.
✓ Branch 2 taken 7883 times.
✓ Branch 3 taken 8961 times.
✓ Branch 4 taken 12232 times.
41470 switch(misc&3)
14691 {
14692 case down:
14693 8961 flip=2;
14694
14695 [[fallthrough]];
14696 case up:
14697 21355 tile=(clk3)?188:189;
14698 21355 break;
14699
14700 case right:
14701 12232 flip=1;
14702 [[fallthrough]];
14703
14704 case left:
14705 20115 tile=(clk3)?186:187;
14706 20115 break;
14707 }
14708 }
14709
14710 200186 enemy::draw(dest);
14711 200186 }
14712
14713 168 eGleeok::eGleeok(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) //enemy((zfix)120,(zfix)48,Id,Clk)
14714 168 {
14715
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 if ( !(editorflags & ENEMY_FLAG5) )
14716 {
14717
2/4
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 168 times.
✗ Branch 3 not taken.
168 std::tie(x, y) = translate_screen_coordinates_to_world(screen_spawned, 120, 48);
14718 168 }
14719 else
14720 {
14721 if ( !(editorflags & ENEMY_FLAG6) )
14722 {
14723 x = X; y = Y;
14724 }
14725 else
14726 {
14727 x = X+8; y = Y;
14728 }
14729 }
14730 168 hzsz = 32; // can't be jumped.
14731 168 flameclk=0;
14732 168 misc=clk; // total head count
14733 168 clk3=clk; // live head count
14734 168 clk=0;
14735 168 clk2=60; // fire ball clock
14736 // hp=(guysbuf[eGLEEOK2+(misc-2)].misc2)*(misc-1)*game->get_hero_dmgmult()+guysbuf[eGLEEOK2+(misc-2)].hp;
14737
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 hp=(guysbuf[id&0xFFF].attributes[1])*(misc-1)*game->get_hero_dmgmult()+guysbuf[id&0xFFF].hp;
14738 168 dir = down;
14739 168 hxofs=4;
14740 168 hit_width=8;
14741 // frate=17*4;
14742 168 fading=fade_blue_poof;
14743 //nets+5420;
14744
2/2
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 35 times.
168 if(get_qr(qr_NEWENEMYTILES))
14745 {
14746 /*
14747 necktile=o_tile+8;
14748 if (dmisc3)
14749 {
14750 necktile+=8;
14751 }
14752 */
14753 133 necktile=o_tile+dmisc6;
14754 133 }
14755 else
14756 {
14757 35 necktile=s_tile;
14758 }
14759 168 }
14760
14761 155290 bool eGleeok::animate(int32_t index)
14762 {
14763
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 155290 times.
155290 if(switch_hooked) return enemy::animate(index);
14764
2/2
✓ Branch 0 taken 2199 times.
✓ Branch 1 taken 153091 times.
155290 if(dying)
14765 2199 return Dead(index);
14766
14767
2/2
✓ Branch 0 taken 152407 times.
✓ Branch 1 taken 684 times.
153091 if(clk==0)
14768 {
14769 684 removearmos(x,y);
14770 684 }
14771
14772 // Check if a head was killed somehow...
14773
2/2
✓ Branch 0 taken 101719 times.
✓ Branch 1 taken 51372 times.
153091 if(index+1+clk3>=guys.Count())
14774 51372 clk3=guys.Count()-index-1;
14775
2/2
✓ Branch 0 taken 66050 times.
✓ Branch 1 taken 87041 times.
153091 if(index+1+misc>=guys.Count())
14776 87041 misc=guys.Count()-index-1;
14777
14778 //fix for the "kill all enemies" item
14779
2/2
✓ Branch 0 taken 153085 times.
✓ Branch 1 taken 6 times.
153091 if(hp==-1000)
14780 {
14781
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 for(int32_t i=0; i<clk3; ++i)
14782 {
14783 // I haven't seen this fail, but it seems like it ought to be
14784 // possible, so I'm checking for it. - Saf
14785
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if((((enemy*)guys.spr(index+i+1))->id&0xFFF)!=(id&0xFFF))
14786 break;
14787 12 ((enemy*)guys.spr(index+i+1))->hp=1; // re-animate each head,
14788 12 ((enemy*)guys.spr(index+i+1))->misc = -1; // disconnect it,
14789 12 ((enemy*)guys.spr(index+i+1))->animate(index+i+1); // let it animate one frame,
14790 12 ((enemy*)guys.spr(index+i+1))->hp=-1000; // and kill it for good
14791 12 }
14792
14793 6 clk3=0;
14794
14795
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 for(int32_t i=0; i<misc; i++)
14796 {
14797
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if((((enemy*)guys.spr(index+i+1))->id&0xFFF)!=(id&0xFFF))
14798 break;
14799 12 ((enemy*)guys.spr(index+i+1))->misc = -2; // give the signal to disappear
14800 12 }
14801 6 }
14802
14803
2/2
✓ Branch 0 taken 403171 times.
✓ Branch 1 taken 153091 times.
556262 for(int32_t i=0; i<clk3; i++)
14804 {
14805 403171 enemy *head = ((enemy*)guys.spr(index+i+1));
14806 403171 head->dummy_int[1]=necktile;
14807 403171 head->setParent(this);
14808
14809
2/2
✓ Branch 0 taken 320127 times.
✓ Branch 1 taken 83044 times.
403171 if(get_qr(qr_NEWENEMYTILES))
14810 {
14811 320127 head->dummy_int[2]=o_tile+dmisc8; //connected head tile
14812 320127 head->dummy_int[3]=o_tile+dmisc9; //flying head tile
14813 320127 }
14814 else
14815 {
14816 83044 head->dummy_int[2]=necktile+1; //connected head tile
14817 83044 head->dummy_int[3]=necktile+2; //flying head tile
14818 }
14819
14820 403171 head->dmisc5=dmisc5; //neck segments
14821
14822 /*
14823 if (dmisc3)
14824 {
14825 head->dummy_bool[0]=true;
14826 }
14827 */
14828
2/2
✓ Branch 0 taken 397516 times.
✓ Branch 1 taken 5655 times.
403171 if(head->hclk)
14829 {
14830
2/2
✓ Branch 0 taken 4427 times.
✓ Branch 1 taken 1228 times.
5655 if(hclk==0)
14831 {
14832 1228 hp -= 1000 - head->hp;
14833 1228 hclk = 33;
14834
14835
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1228 times.
1228 if(hitsfx>0) sfx(hitsfx,pan(int32_t(head->x)));
14836
14837 1228 sfx(WAV_EHIT,pan(int32_t(head->x)));
14838 1228 }
14839
14840 5655 head->hclk = 0;
14841 5655 }
14842
14843 // Must be set in case of naughty ZScripts
14844 403171 head->hp = 1000;
14845 403171 }
14846
14847
2/2
✓ Branch 0 taken 152676 times.
✓ Branch 1 taken 415 times.
153091 if(hp<=(guysbuf[id&0xFFF].attributes[1]) * (clk3 - 1) * game->get_hero_dmgmult())
14848 {
14849 415 ((enemy*)guys.spr(index+clk3))->misc = -1; // give signal to fly off
14850 415 hp=(guysbuf[id&0xFFF].attributes[1])*(--clk3)*game->get_hero_dmgmult();
14851 415 }
14852
14853
2/2
✓ Branch 0 taken 57409 times.
✓ Branch 1 taken 95682 times.
153091 if(!dmisc3)
14854 {
14855
4/4
✓ Branch 0 taken 5291 times.
✓ Branch 1 taken 90391 times.
✓ Branch 2 taken 1287 times.
✓ Branch 3 taken 4004 times.
95682 if(++clk2>72 && !(zc_oldrand()&3))
14856 {
14857 1287 int32_t i = zc::math::SafeMod(zc_oldrand(), misc);
14858 1287 enemy *head = ((enemy*)guys.spr(index+i+1));
14859 1287 addEwpn(head->x,head->y,head->z,wpn,3,wdp,dir,getUID(), 0, head->fakez);
14860 1287 sfx(wpnsfx(wpn),pan(x));
14861 1287 clk2=0;
14862 1287 }
14863 95682 }
14864 else
14865 {
14866
4/4
✓ Branch 0 taken 2357 times.
✓ Branch 1 taken 55052 times.
✓ Branch 2 taken 1800 times.
✓ Branch 3 taken 557 times.
57409 if(++clk2>100 && !(zc_oldrand()&3))
14867 {
14868 557 enemy *head = ((enemy*)guys.spr(zc::math::SafeMod(zc_oldrand(), misc) + index + 1));
14869 557 head->timer=zc_oldrand()%50+50;
14870 557 clk2=0;
14871 557 }
14872 }
14873
14874
3/4
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 152964 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 127 times.
153091 if((hp<=0 && !immortal))
14875 {
14876
2/2
✓ Branch 0 taken 390 times.
✓ Branch 1 taken 127 times.
517 for(int32_t i=0; i<misc; i++)
14877 390 ((enemy*)guys.spr(index+i+1))->misc = -2; // give the signal to disappear
14878
14879
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 124 times.
127 if(flags&guy_never_return) never_return(screen_spawned, index);
14880 127 }
14881
14882 153091 return enemy::animate(index);
14883 155290 }
14884
14885 1239 int32_t eGleeok::takehit(weapon*,weapon*)
14886 {
14887 1239 return 0;
14888 }
14889
14890 156918 void eGleeok::draw(BITMAP *dest)
14891 {
14892 156918 tile=o_tile;
14893
14894
2/2
✓ Branch 0 taken 2199 times.
✓ Branch 1 taken 154719 times.
156918 if(dying)
14895 {
14896 2199 enemy::draw(dest);
14897 2199 return;
14898 }
14899
14900 154719 int32_t f=clk/17;
14901
14902
2/2
✓ Branch 0 taken 120524 times.
✓ Branch 1 taken 34195 times.
154719 if(get_qr(qr_NEWENEMYTILES))
14903 {
14904 // body
14905 120524 xofs=-8;
14906 120524 yofs=32;
14907
14908
4/4
✓ Branch 0 taken 92588 times.
✓ Branch 1 taken 9155 times.
✓ Branch 2 taken 10095 times.
✓ Branch 3 taken 8686 times.
120524 switch(f)
14909
14910 {
14911 case 0:
14912 9155 tile+=0;
14913 9155 break;
14914
14915 case 1:
14916 10095 tile+=2;
14917 10095 break;
14918
14919 case 2:
14920 8686 tile+=4;
14921 8686 break;
14922
14923 default:
14924 92588 tile+=6;
14925 92588 break;
14926 }
14927 120524 }
14928 else
14929 {
14930 // body
14931 34195 xofs=-8;
14932 34195 yofs=32;
14933
14934
3/3
✓ Branch 0 taken 29222 times.
✓ Branch 1 taken 2514 times.
✓ Branch 2 taken 2459 times.
34195 switch(f)
14935 {
14936 case 0:
14937 2514 tile+=0;
14938 2514 break;
14939
14940 case 2:
14941 2459 tile+=4;
14942 2459 break;
14943
14944 default:
14945 29222 tile+=2;
14946 29222 break;
14947 }
14948 }
14949
14950 154719 enemy::drawblock(dest,15);
14951 156918 }
14952
14953 156918 void eGleeok::draw2(BITMAP *dest)
14954 {
14955 // the neck stub
14956 156918 tile=necktile;
14957 156918 xofs=0;
14958
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156918 times.
156918 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
14959
14960
2/2
✓ Branch 0 taken 34737 times.
✓ Branch 1 taken 122181 times.
156918 if(get_qr(qr_NEWENEMYTILES))
14961 {
14962 122181 tile+=((clk&24)>>3);
14963 122181 }
14964
14965
3/4
✓ Branch 0 taken 154719 times.
✓ Branch 1 taken 2199 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 154719 times.
156918 if(hp > 0 && !dont_draw())
14966 {
14967 154719 mapscr* scr = get_scr(screen_spawned);
14968
4/4
✓ Branch 0 taken 4731 times.
✓ Branch 1 taken 149988 times.
✓ Branch 2 taken 737 times.
✓ Branch 3 taken 3994 times.
154719 if((scr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
14969 737 sprite::drawcloaked(dest);
14970 else
14971 153982 sprite::draw(dest);
14972 154719 }
14973 156918 }
14974
14975
3/6
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
1066 esGleeok::esGleeok(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk)
14976 533 {
14977
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 setParent(prnt);
14978
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 xoffset=0;
14979
2/4
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
533 yoffset=(zfix)((dmisc5*4+2));
14980 // dummy_bool[0]=false;
14981 533 timer=0;
14982 /* fixing */
14983 533 hp=1000;
14984
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 step=1;
14985 533 item_set=0;
14986
4/8
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 533 times.
✗ Branch 7 not taken.
533 x = xoffset+parent->x;
14987
4/8
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 533 times.
✗ Branch 7 not taken.
533 y = yoffset+parent->y;
14988 533 hxofs=4;
14989 533 hit_width=8;
14990
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 533 times.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
533 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
14991 533 clk2=clk; // how int32_t to wait before moving first time
14992 533 clk=0;
14993 533 mainguy=count_enemy=false;
14994
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 dir=zc_oldrand();
14995 533 clk3=((dir&2)>>1)+2; // left or right
14996 533 dir&=1; // up or down
14997
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 dmisc5=vbound(dmisc5,1,255);
14998 533 isCore = false;
14999
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 parentCore = parent->getUID();
15000
2/2
✓ Branch 0 taken 2132 times.
✓ Branch 1 taken 533 times.
2665 for(int32_t i=0; i<dmisc5; i++)
15001 {
15002 2132 nxoffset[i] = 0;
15003 2132 nyoffset[i] = 0;
15004
2/4
✓ Branch 0 taken 2132 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2132 times.
✗ Branch 3 not taken.
2132 nx[i] = ((((i*(int32_t)x) + (dmisc5-i)*((int32_t)parent->x))) /dmisc5);
15005
2/4
✓ Branch 0 taken 2132 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2132 times.
✗ Branch 3 not taken.
2132 ny[i] = ((((i*(int32_t)y) + (dmisc5-i)*((int32_t)parent->y))) /dmisc5);
15006 2132 }
15007
15008 533 necktile=0;
15009 //TODO compatibility? -DD
15010 /*
15011 for(int32_t i=0; i<4; i++)
15012 {
15013 nx[i]=124;
15014 ny[i]=i*6+48;
15015 }*/
15016 533 bgsfx=-1;
15017 //no need for deadsfx
15018 533 }
15019
15020 515535 bool esGleeok::animate(int32_t index)
15021 {
15022
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 515535 times.
515535 if(switch_hooked) return enemy::animate(index);
15023 // don't call removearmos() - it's a segment.
15024
15025 515535 dmisc5=vbound(dmisc5,1,255);
15026
15027
2/2
✓ Branch 0 taken 112773 times.
✓ Branch 1 taken 402762 times.
515535 if(misc == 0)
15028 {
15029 402762 x = (xoffset+parent->x);
15030 402762 y = (yoffset+parent->y);
15031
15032
2/2
✓ Branch 0 taken 1611048 times.
✓ Branch 1 taken 402762 times.
2013810 for(int32_t i=0; i<dmisc5; i++)
15033 {
15034 1611048 nx[i] = ((((i*(int32_t)x) + (dmisc5-i)*((int32_t)parent->x))) /dmisc5) + 3 + nxoffset[i];
15035 1611048 ny[i] = ((((i*(int32_t)y) + (dmisc5-i)*((int32_t)parent->y))) /dmisc5) + nyoffset[i];
15036 1611048 }
15037 402762 }
15038
15039 // set up the head tiles
15040 // headtile=nets+5588; //5580, actually. must adjust for direction later on
15041 /*
15042 if (dummy_bool[0]) //if this is a flame gleeok
15043 {
15044 headtile+=180;
15045 }
15046 */
15047 515535 headtile=dummy_int[2]; //5580, actually. must adjust for direction later on
15048 515535 flyingheadtile=dummy_int[3];
15049
15050 // set up the neck tiles
15051 515535 necktile=dummy_int[1];
15052
15053
2/2
✓ Branch 0 taken 112702 times.
✓ Branch 1 taken 402833 times.
515535 if(get_qr(qr_NEWENEMYTILES))
15054 {
15055 402833 necktile+=((clk&24)>>3);
15056 402833 }
15057
15058 /*
15059 else
15060 {
15061 necktile=145;
15062 }
15063 */
15064 // ?((dummy_bool[0])?(nets+4052+(16+((clk&24)>>3))):(nets+4040+(8+((clk&24)>>3)))):145)
15065
15066
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 402762 times.
✓ Branch 2 taken 112071 times.
✓ Branch 3 taken 300 times.
✓ Branch 4 taken 402 times.
515535 switch(misc)
15067 {
15068 case 0: // live head
15069 // set up the attached head tiles
15070 402762 tile=headtile;
15071
15072
2/2
✓ Branch 0 taken 82942 times.
✓ Branch 1 taken 319820 times.
402762 if(get_qr(qr_NEWENEMYTILES))
15073 {
15074 319820 tile+=((clk&24)>>3);
15075 /*
15076 if (dummy_bool[0]) {
15077 tile+=1561;
15078 }
15079 */
15080 319820 }
15081
15082 /*
15083 else
15084 {
15085 tile=146;
15086 }
15087 */
15088
4/4
✓ Branch 0 taken 104448 times.
✓ Branch 1 taken 298314 times.
✓ Branch 2 taken 11616 times.
✓ Branch 3 taken 92832 times.
402762 if(++clk2>=0 && !(clk2&3))
15089 {
15090
2/2
✓ Branch 0 taken 90773 times.
✓ Branch 1 taken 2059 times.
92832 if(y<= (int32_t)parent->y + 8) dir=down;
15091
15092
2/2
✓ Branch 0 taken 90911 times.
✓ Branch 1 taken 1921 times.
92832 if(y>= (int32_t)parent->y + dmisc5*8) dir = up;
15093
15094
4/4
✓ Branch 0 taken 9757 times.
✓ Branch 1 taken 83075 times.
✓ Branch 2 taken 9465 times.
✓ Branch 3 taken 292 times.
92832 if(y<= (int32_t)parent->y + 10 && !(zc_oldrand()&31))
15095 {
15096 292 dir^=1;
15097 292 }
15098
15099 92832 zfix tempx = x;
15100 92832 zfix tempy = y;
15101
15102 92832 sprite::move(step);
15103 92832 xoffset += (x-tempx);
15104 92832 yoffset += (y-tempy);
15105
15106
2/2
✓ Branch 0 taken 3863 times.
✓ Branch 1 taken 88969 times.
92832 if(clk2>=4)
15107 {
15108 3863 clk3^=1;
15109 3863 clk2=-4;
15110 3863 }
15111 else
15112 {
15113
2/2
✓ Branch 0 taken 87991 times.
✓ Branch 1 taken 978 times.
88969 if(x <= (int32_t)parent->x-(dmisc5*6))
15114 {
15115 978 clk3=right;
15116 978 }
15117
15118
2/2
✓ Branch 0 taken 88008 times.
✓ Branch 1 taken 961 times.
88969 if(x >= (int32_t)parent->x+(dmisc5*6))
15119 {
15120 961 clk3=left;
15121 961 }
15122
15123
4/4
✓ Branch 0 taken 60029 times.
✓ Branch 1 taken 28940 times.
✓ Branch 2 taken 56316 times.
✓ Branch 3 taken 3713 times.
88969 if(y <= (int32_t)parent->y+(dmisc5*6) && !(zc_oldrand()&15))
15124 {
15125 3713 clk3^=1; // x jig
15126 3713 }
15127 else
15128 {
15129
4/4
✓ Branch 0 taken 29223 times.
✓ Branch 1 taken 56033 times.
✓ Branch 2 taken 28372 times.
✓ Branch 3 taken 851 times.
85256 if(y<=(int32_t)parent->y+(dmisc5*4) && !(zc_oldrand()&31))
15130 {
15131 851 clk3^=1; // x switch back
15132 851 }
15133
15134 85256 clk2=-4;
15135 }
15136 }
15137
15138 92832 zc_swap(dir,clk3);
15139 92832 tempx = x;
15140 92832 tempy = y;
15141 92832 sprite::move(step);
15142 92832 xoffset += (x-tempx);
15143 92832 yoffset += (y-tempy);
15144 92832 zc_swap(dir,clk3);
15145
15146
2/2
✓ Branch 0 taken 278496 times.
✓ Branch 1 taken 92832 times.
371328 for(int32_t i=1; i<dmisc5; i++)
15147 {
15148 278496 nxoffset[i] = (zc_oldrand()%3);
15149 278496 nyoffset[i] = (zc_oldrand()%3);
15150 278496 }
15151 92832 }
15152
15153 402762 break;
15154
15155 case 1: // flying head
15156
2/2
✓ Branch 0 taken 6589 times.
✓ Branch 1 taken 105482 times.
112071 if(clk>=0)
15157
15158 {
15159 105482 variable_walk_8(rate,homing,hrate,spw_floater);
15160 105482 }
15161
15162 112071 break;
15163
15164 // the following are messages sent from the main guy...
15165 case -1: // got chopped off
15166 {
15167 300 misc=1;
15168 300 superman=1;
15169 300 hxofs=xofs=0;
15170 300 hit_width=16;
15171 300 cs=8;
15172 300 clk=-24;
15173 300 clk2=40;
15174 300 dir=(zc_oldrand()&7)+8;
15175 300 step=8.0/9.0;
15176 }
15177 300 break;
15178
15179 case -2: // the big guy is dead
15180 402 return true;
15181 }
15182
15183
2/2
✓ Branch 0 taken 475008 times.
✓ Branch 1 taken 40125 times.
515133 if(timer)
15184 {
15185
2/2
✓ Branch 0 taken 35334 times.
✓ Branch 1 taken 4791 times.
40125 if(!(timer%8))
15186 {
15187 4791 FireBreath(true);
15188 4791 }
15189
15190 40125 --timer;
15191 40125 }
15192
15193 515133 return enemy::animate(index);
15194 515535 }
15195
15196 7080 int32_t esGleeok::takehit(weapon *w, weapon* realweap)
15197 {
15198
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7080 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7080 if ((editorflags & ENEMY_FLAG7) && misc == 1)
15199 {
15200 int32_t wpnId = w->id;
15201
15202 if(dying)
15203 return 0;
15204
15205 switch(wpnId)
15206 {
15207 case wLitBomb:
15208 case wLitSBomb:
15209 case wBait:
15210 case wWhistle:
15211 case wFire:
15212 case wWind:
15213 case wSSparkle:
15214 case wFSparkle:
15215 case wPhantom:
15216 return 0;
15217
15218 case wHookshot:
15219 case wBrang:
15220 case wBeam:
15221 case wArrow:
15222 case wMagic:
15223 case wBomb:
15224 case wSBomb:
15225 sfx(WAV_CHINK,pan(x));
15226 break;
15227 default:
15228 break;
15229 }
15230
15231 return 1;
15232 }
15233 else
15234 {
15235 7080 int32_t ret = enemy::takehit(w,realweap);
15236
15237
2/2
✓ Branch 0 taken 1425 times.
✓ Branch 1 taken 5655 times.
7080 if(ret==-1)
15238 5655 return -2; // force it to wait a frame before checking sword attacks again
15239
15240 1425 return ret;
15241 }
15242 7080 }
15243
15244 521456 void esGleeok::draw(BITMAP *dest)
15245 {
15246 521456 dmisc5=vbound(dmisc5,1,255);
15247
15248
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 409106 times.
✓ Branch 2 taken 112350 times.
521456 switch(misc)
15249 {
15250 case 0: //neck
15251
1/2
✓ Branch 0 taken 409106 times.
✗ Branch 1 not taken.
409106 if(!dont_draw())
15252 {
15253
2/2
✓ Branch 0 taken 1227318 times.
✓ Branch 1 taken 409106 times.
1636424 for(int32_t i=1; i<dmisc5; i++) //draw the neck
15254 {
15255 1227318 mapscr* scr = get_scr(screen_spawned);
15256
2/2
✓ Branch 0 taken 978198 times.
✓ Branch 1 taken 249120 times.
1227318 if(get_qr(qr_NEWENEMYTILES))
15257 {
15258
4/4
✓ Branch 0 taken 23100 times.
✓ Branch 1 taken 955098 times.
✓ Branch 2 taken 20889 times.
✓ Branch 3 taken 2211 times.
978198 if((scr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
15259 2211 overtilecloaked16(dest,necktile+(i*dmisc7),nx[i]-4-viewport.x,ny[i]+playing_field_offset-viewport.y,0);
15260 else
15261 975987 overtile16(dest,necktile+(i*dmisc7),nx[i]-4-viewport.x,ny[i]+playing_field_offset-viewport.y,cs,0);
15262 978198 }
15263 else
15264 {
15265
3/4
✓ Branch 0 taken 4278 times.
✓ Branch 1 taken 244842 times.
✓ Branch 2 taken 4278 times.
✗ Branch 3 not taken.
249120 if((scr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
15266 overtilecloaked16(dest,necktile,nx[i]-4-viewport.x,ny[i]+playing_field_offset-viewport.y,0);
15267 else
15268 249120 overtile16(dest,necktile,nx[i]-4-viewport.x,ny[i]+playing_field_offset-viewport.y,cs,0);
15269 }
15270 1227318 }
15271 409106 }
15272
15273 409106 break;
15274
15275 case 1: //flying head
15276 112350 tile=flyingheadtile;
15277
15278
2/2
✓ Branch 0 taken 82692 times.
✓ Branch 1 taken 29658 times.
112350 if(get_qr(qr_NEWENEMYTILES))
15279 {
15280 82692 tile+=((clk&24)>>3);
15281 82692 break;
15282 }
15283 29658 }
15284 521456 }
15285
15286 521456 void esGleeok::draw2(BITMAP *dest)
15287 {
15288 521456 enemy::draw(dest);
15289 521456 }
15290
15291 190 ePatra::ePatra(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)// enemy((zfix)128,(zfix)48,Id,Clk)
15292 190 {
15293
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if ( !(editorflags & ENEMY_FLAG5) )
15294 {
15295
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 x = 128;
15296
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 y = 48;
15297 190 }
15298 else { x = X; y = Y; }
15299 190 adjusted=false;
15300
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 dir=(zc_oldrand()&7)+8;
15301 //step=0.25;
15302 190 flycnt=dmisc1;
15303 190 flycnt2=dmisc2;
15304 190 loopcnt=0;
15305 190 clk4 = 0;
15306 190 clk5 = 0;
15307 190 clk6 = 0;
15308 190 clk7 = 0;
15309
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if(dmisc6<int16_t(1))dmisc6=1; // ratio cannot be 0!
15310
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if (dmisc29 == 0)
15311 {
15312
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 105 times.
190 if(!dmisc4)
15313 {
15314
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc29 = (90 / 3);
15315 105 else dmisc29 = (84 / 3);
15316 105 }
15317 else
15318 {
15319
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (dmisc10) dmisc29 = (90 / 2);
15320 85 else dmisc29 = (84 / 2);
15321 }
15322 190 }
15323
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if (dmisc30 == 0)
15324 {
15325
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 105 times.
190 if(!dmisc4)
15326 {
15327
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc30 = (90 / 3)*0.5;
15328 105 else dmisc30 = (84 / 3)*0.5;
15329 105 }
15330 else
15331 {
15332
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (dmisc10) dmisc30 = (90 / 2)*0.5;
15333 85 else dmisc30 = (84 / 2)*0.5;
15334 }
15335 190 }
15336
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if (dmisc31 == 0)
15337 {
15338
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 105 times.
190 if(!dmisc4)
15339 {
15340
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc31 = (90 / 3)*2;
15341 105 else dmisc31 = (84 / 3)*2;
15342 105 }
15343 else
15344 {
15345
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (dmisc10) dmisc31 = (90 / 2)*0.5;
15346 85 else dmisc31 = (84 / 2)*0.5;
15347 }
15348 190 }
15349
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if (dmisc32 == 0)
15350 {
15351
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 105 times.
190 if(!dmisc4)
15352 {
15353
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc32 = (90 / 3);
15354 105 else dmisc32 = (84 / 3);
15355 105 }
15356 else
15357 {
15358
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (dmisc10) dmisc32 = (90 / 2)*0.25;
15359 85 else dmisc32 = (84 / 2)*0.25;
15360 }
15361 190 }
15362
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 init_size_flags();
15363 190 }
15364
15365 161885 bool ePatra::animate(int32_t index)
15366 {
15367
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 161885 times.
161885 if(switch_hooked) return enemy::animate(index);
15368
2/2
✓ Branch 0 taken 1444 times.
✓ Branch 1 taken 160441 times.
161885 if(dying)
15369 {
15370
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 1444 times.
1516 for(int32_t i=index+1; i<index+flycnt+flycnt2+1; i++)
15371 {
15372 72 auto segment = (enemy*)guys.spr(i);
15373
2/4
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 72 times.
72 if (segment && segment->parent == this)
15374 72 segment->hp = -1000;
15375 72 }
15376
15377 1444 return Dead(index);
15378 }
15379
15380 160441 double basesize = 84;
15381
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (dmisc10) basesize = 90;
15382 160441 double halfsize = basesize / 2;
15383 160441 double quartersize = halfsize / 2;
15384 160441 double twothirdsize = (basesize / 3)*2;
15385 160441 double onethirdsize = (basesize / 3);
15386
15387
15388
2/2
✓ Branch 0 taken 123507 times.
✓ Branch 1 taken 36934 times.
160441 if(clk==0)
15389 {
15390 36934 removearmos(x,y);
15391 36934 }
15392
15393
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 160441 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 160441 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
160441 if ((clk4 <=0 || clk4%2) && (clk7 <= 0 || clk6 <= -16))
15394 {
15395
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 160441 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
160441 if (!dmisc22 || loopcnt == 0 || (dmisc22 == 1 && loopcnt < 0)) variable_walk_8(rate,homing,hrate,spw_floater);
15396
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (loopcnt < 0) ++clk2;
15397
2/2
✓ Branch 0 taken 158644 times.
✓ Branch 1 taken 1797 times.
160441 if(++clk2>basesize)
15398 {
15399 1797 clk2=0;
15400
2/12
✗ Branch 0 not taken.
✓ Branch 1 taken 1797 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1797 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
1797 if ((!dmisc26 || (dmisc26 == 1 && flycnt) || (dmisc26 == 2 && !flycnt)) && (!(editorflags & ENEMY_FLAG10) || flycnt || flycnt2))
15401 {
15402
2/2
✓ Branch 0 taken 932 times.
✓ Branch 1 taken 865 times.
1797 if(loopcnt > 0)
15403 932 --loopcnt;
15404
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865 times.
865 else if (loopcnt == 0)
15405 {
15406
2/2
✓ Branch 0 taken 509 times.
✓ Branch 1 taken 356 times.
865 if (zc::math::SafeMod(misc, dmisc6) == 0)
15407 {
15408
1/2
✓ Branch 0 taken 356 times.
✗ Branch 1 not taken.
356 if (dmisc21 > 0) loopcnt=-dmisc21;
15409 356 else loopcnt=dmisc7;
15410 356 }
15411 865 }
15412 else if (loopcnt == -1) loopcnt=dmisc7;
15413 else ++loopcnt;
15414
15415
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1797 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1797 if (!(editorflags & ENEMY_FLAG9) || loopcnt == 0) ++misc;
15416 1797 }
15417 else
15418 {
15419 loopcnt = 0;
15420 misc = 1;
15421 }
15422 1797 }
15423 160441 }
15424
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (clk4 > 0) --clk4;
15425
15426
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (clk6 < 0)
15427 {
15428 if (dmisc5 == 1 || dmisc5 == 3)
15429 {
15430 if (get_qr(qr_NEWENEMYTILES))
15431 {
15432 if (clk7 <= 0 || clk6 != -16) ++clk6;
15433 if (clk6 == 0) o_tile=d->e_tile;
15434 else
15435 {
15436 if (clk6 >= -16) o_tile=d->e_tile + (IsBigAnim() ? 320 : 80);
15437 else o_tile=d->e_tile + (IsBigAnim() ? 160 : 40);
15438 }
15439 }
15440 else clk6 = 0;
15441 }
15442 }
15443
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 else if (dmisc19) ++clk6;
15444
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (clk5 < 0) ++clk5;
15445
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 else if (dmisc19) ++clk5;
15446
15447
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 160441 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
160441 if (clk7 > 0 && clk6 >= -16) --clk7;
15448
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (clk6 > 0) clk7 = 0;
15449
15450
2/2
✓ Branch 0 taken 660384 times.
✓ Branch 1 taken 160441 times.
820825 for(int32_t i=index+1; i<index+flycnt+1; i++)
15451 {
15452 //outside ring
15453
2/2
✓ Branch 0 taken 659040 times.
✓ Branch 1 taken 1344 times.
660384 if(!adjusted)
15454 {
15455
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 192 times.
1344 if(get_qr(qr_NEWENEMYTILES))
15456 {
15457 1152 ((enemy*)guys.spr(i))->o_tile=d->e_tile+dmisc8;
15458 1152 enemy *s = ((enemy*)guys.spr(i));
15459 1152 s->setParent(this);
15460 1152 }
15461 else
15462 {
15463 192 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
15464 192 enemy *s = ((enemy*)guys.spr(i));
15465 192 s->setParent(this);
15466 }
15467
15468 1344 ((enemy*)guys.spr(i))->cs=dmisc9;
15469 1344 ((enemy*)guys.spr(i))->hp=dmisc3;
15470 1344 }
15471
15472
2/2
✓ Branch 0 taken 764 times.
✓ Branch 1 taken 659620 times.
660384 if(((enemy*)guys.spr(i))->hp <= 0)
15473 {
15474
2/2
✓ Branch 0 taken 2889 times.
✓ Branch 1 taken 764 times.
3653 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
15475 {
15476 2889 guys.swap(j,j+1);
15477 2889 }
15478
15479
3/4
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 670 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 94 times.
764 if (--flycnt == 0 && dmisc23 != 0) step += zslongToFix(dmisc23*100);
15480 764 }
15481 else
15482 {
15483 659620 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
15484
1/2
✓ Branch 0 taken 659620 times.
✗ Branch 1 not taken.
659620 double a2 = (clk2-pos2*(double)basesize/(dmisc1 == 0 ? 1 : dmisc1))*PI/halfsize;
15485
15486
2/2
✓ Branch 0 taken 212037 times.
✓ Branch 1 taken 447583 times.
659620 if(!dmisc4) //Big Ring
15487 {
15488 //maybe playing_field_offset here?
15489
2/2
✓ Branch 0 taken 237330 times.
✓ Branch 1 taken 210253 times.
447583 if(loopcnt>0)
15490 {
15491
1/2
✓ Branch 0 taken 237330 times.
✗ Branch 1 not taken.
237330 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc31) - zc::math::Sin(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1))*((int64_t)abs(dmisc31)-abs(dmisc29));
15492
1/2
✓ Branch 0 taken 237330 times.
✗ Branch 1 not taken.
237330 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc31) + zc::math::Cos(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1))*((int64_t)abs(dmisc31)-abs(dmisc29));
15493 237330 }
15494 else
15495 {
15496 210253 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
15497 210253 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc29);
15498 }
15499
15500 447583 temp_x=guys.spr(i)->x;
15501 447583 temp_y=guys.spr(i)->y;
15502 447583 }
15503 else //Oval
15504 {
15505 212037 circle_x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
15506 212037 circle_y = -zc::math::Sin(a2+PI/2)*abs(dmisc29);
15507
15508
2/2
✓ Branch 0 taken 121041 times.
✓ Branch 1 taken 90996 times.
212037 if(loopcnt>0)
15509 {
15510 121041 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
15511
1/2
✓ Branch 0 taken 121041 times.
✗ Branch 1 not taken.
121041 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1)))*abs(dmisc31);
15512 121041 }
15513 else
15514 {
15515 90996 guys.spr(i)->x = circle_x;
15516 90996 guys.spr(i)->y = circle_y;
15517 }
15518
15519 212037 temp_x=circle_x;
15520 212037 temp_y=circle_y;
15521 }
15522
15523 double _MSVC2022_tmp1, _MSVC2022_tmp2;
15524 659620 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
15525
15526
4/4
✓ Branch 0 taken 124008 times.
✓ Branch 1 taken 535612 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 83117 times.
659620 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
15527 {
15528 83117 guys.spr(i)->dir=l_down;
15529 83117 }
15530
4/4
✓ Branch 0 taken 124459 times.
✓ Branch 1 taken 452044 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 83568 times.
576503 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
15531 {
15532 83568 guys.spr(i)->dir=left;
15533 83568 }
15534
4/4
✓ Branch 0 taken 123345 times.
✓ Branch 1 taken 369590 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 82454 times.
492935 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
15535 {
15536 82454 guys.spr(i)->dir=l_up;
15537 82454 }
15538
4/4
✓ Branch 0 taken 123079 times.
✓ Branch 1 taken 287402 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 82188 times.
410481 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
15539 {
15540 82188 guys.spr(i)->dir=up;
15541 82188 }
15542
4/4
✓ Branch 0 taken 122491 times.
✓ Branch 1 taken 205802 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 81600 times.
328293 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
15543 {
15544 81600 guys.spr(i)->dir=r_up;
15545 81600 }
15546
4/4
✓ Branch 0 taken 122884 times.
✓ Branch 1 taken 123809 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 81993 times.
246693 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
15547 {
15548 81993 guys.spr(i)->dir=right;
15549 81993 }
15550
4/4
✓ Branch 0 taken 122590 times.
✓ Branch 1 taken 42110 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 81699 times.
164700 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
15551 {
15552 81699 guys.spr(i)->dir=r_down;
15553 81699 }
15554 else
15555 {
15556 83001 guys.spr(i)->dir=down;
15557 }
15558
15559 659620 guys.spr(i)->x += x;
15560 659620 guys.spr(i)->y += y;
15561 }
15562 660384 }
15563
15564
7/22
✓ Branch 0 taken 106957 times.
✓ Branch 1 taken 53484 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 106957 times.
✓ Branch 4 taken 21153 times.
✓ Branch 5 taken 32331 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 21153 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 32331 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
160441 if((wpn>wEnemyWeapons || (wpn >= wScript1 && wpn <= wScript10)) && (dmisc5==1 || dmisc5== 3) && (!dmisc25 || (dmisc25 == 1 && !flycnt && !flycnt2) || (dmisc25 == 2 && (flycnt || flycnt2)) || (dmisc25 == 3 && flycnt2 && !flycnt)))
15565 {
15566 32331 int timeneeded = 48;
15567 32331 int patbreath = (zc_oldrand()%50+50);
15568
2/2
✓ Branch 0 taken 24549 times.
✓ Branch 1 taken 7782 times.
32331 if ((patbreath % 4) == 0) ++patbreath;
15569
1/2
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
32331 if (dmisc28 == patratBREATH)
15570 {
15571 timeneeded = 48 + patbreath;
15572 }
15573
1/2
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
32331 if (dmisc28 == patratSTREAM)
15574 {
15575 timeneeded = 48 + 96;
15576 }
15577
4/14
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 32331 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 249 times.
✓ Branch 11 taken 249 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
32331 if (((((dmisc18 > 0 || ((editorflags & ENEMY_FLAG10) && !flycnt && !flycnt2)) && !(zc_oldrand() % zc_max(dmisc18, 1))) || //New 1/N chance
15578
2/2
✓ Branch 0 taken 32331 times.
✓ Branch 1 taken 249 times.
32580 (dmisc18 == 0 && !(zc_oldrand()&127)) //Old hardcoded firing chance
15579
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 32082 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
32580 || (dmisc18 == -1 && loopcnt > 0 && (clk2 == round(halfsize) && (!(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
15580 || (clk4 == 10 && (editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)))))
15581 249 && (clk6 >= 0) //if not in the middle of firing...
15582 249 && clk6 >= dmisc19) //if over the set cooldown between shots...
15583
2/6
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 249 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
249 && ((!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 && (basesize*((int64_t)dmisc6 - zc::math::SafeMod(misc, dmisc6))) > timeneeded)) || dmisc18 == -1)) //And lastly, if not in danger of starting a loop during the attack.
15584 {
15585
1/3
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
249 switch(dmisc28)
15586 {
15587 case patratSTREAM:
15588 {
15589 clk7 = 97;
15590 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) clk6 = -48;
15591 else clk6 = 0;
15592 break;
15593 }
15594 case patratBREATH:
15595 {
15596 clk7 = patbreath;
15597 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) clk6 = -48;
15598 else clk6 = 0;
15599 break;
15600 }
15601 default:
15602 {
15603
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 249 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
249 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
15604 {
15605 clk6 = -48;
15606 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
15607 }
15608 else
15609 {
15610 249 clk6 = 0;
15611
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (editorflags & ENEMY_FLAG6) clk4 = 16;
15612 249 FirePatraWeapon();
15613 }
15614 249 break;
15615 }
15616 } //ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
15617 249 }
15618
1/2
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
32331 if (clk6 < 0)
15619 {
15620 switch(dmisc28)
15621 {
15622 case patratSTREAM:
15623 {
15624 if (clk7 > 0 && (clk7 % 12) == 0) FirePatraWeapon();
15625 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
15626 break;
15627 }
15628 case patratBREATH:
15629 {
15630 if (clk7 > 0 && (clk7 % 4) == 0) FirePatraWeapon();
15631 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
15632 break;
15633 }
15634 default:
15635 {
15636 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && clk6 == -16)
15637 {
15638 FirePatraWeapon();
15639 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
15640 }
15641 break;
15642 }
15643 }
15644 }
15645 32331 }
15646
15647 160441 int randattempts = 0;
15648 160441 int randeye = 0;
15649
2/2
✓ Branch 0 taken 114201 times.
✓ Branch 1 taken 46240 times.
160441 if (flycnt2 > 0)
15650 {
15651 46240 do
15652 {
15653
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 46240 times.
✓ Branch 2 taken 44221 times.
✓ Branch 3 taken 2019 times.
46240 randeye = ((flycnt2 > 0) ? (zc_oldrand() % zc_max(1, flycnt2)) : 0);
15654 46240 randeye += (index + flycnt + 1);
15655 46240 ++randattempts;
15656
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 46240 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 46240 times.
46240 } while (((esPatra*)guys.spr(randeye))->clk5 < 0 && randattempts < 10);
15657 46240 }
15658 160441 bool dofire = false;
15659
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (dmisc20)
15660 {
15661 if ((dmisc18 > 0 && !(zc_oldrand() % zc_max(dmisc18, 1))) ||
15662 (dmisc18 == 0 && !(zc_oldrand()&127)) ||
15663 (dmisc18 == -1 && (loopcnt > 0 || dmisc20 == 4) && ((clk2 == round(halfsize) && (!(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES)) && dmisc20 != 2 && dmisc20 != 4)
15664 || (clk2 == 10 && dmisc20 != 4 && ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) || dmisc20 == 2))
15665 || (((((zc::math::SafeMod(misc, dmisc6) == 0 && (loopcnt == 0 && !dmisc21)) || loopcnt > 1 || loopcnt == -1) && clk2 <= 53 && clk2 >= 51 && (editorflags & ENEMY_FLAG3)) || (!(editorflags & ENEMY_FLAG3) && loopcnt > 0 && clk2 == 1)) && dmisc20 == 4))))
15666 {
15667 if (clk5 >= 0 || !(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
15668 {
15669 if (clk5 >= dmisc19)
15670 {
15671 if ((!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 &&
15672 (dmisc20 == 2 && (basesize*((int64_t)dmisc6 - zc::math::SafeMod(misc, dmisc6))) > ((int64_t)48 + (int64_t(12)*flycnt2))) ||
15673 (dmisc20 == 4 && (basesize*((int64_t)dmisc6 - zc::math::SafeMod(misc, dmisc6))) > ((int64_t)48 + 96)) ||
15674 (dmisc20 != 2 && dmisc20 != 4 && (basesize*((int64_t)dmisc6 - zc::math::SafeMod(misc, dmisc6))) > 48)))
15675 || dmisc18 == -1)
15676 dofire = true;
15677 }
15678 }
15679 }
15680 }
15681
2/2
✓ Branch 0 taken 114201 times.
✓ Branch 1 taken 46240 times.
160441 if(flycnt2)
15682 {
15683
2/2
✓ Branch 0 taken 334429 times.
✓ Branch 1 taken 46240 times.
380669 for(int32_t i=index+flycnt+1; i<index+flycnt+flycnt2+1; i++)//inner ring
15684 {
15685
2/2
✓ Branch 0 taken 334117 times.
✓ Branch 1 taken 312 times.
334429 if(!adjusted)
15686 {
15687 312 ((enemy*)guys.spr(i))->hp=12*game->get_hero_dmgmult();
15688
15689
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if(get_qr(qr_NEWENEMYTILES))
15690 {
15691
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if (get_qr(qr_PATRAS_USE_HARDCODED_OFFSETS))
15692 {
15693
2/3
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 168 times.
✗ Branch 2 not taken.
312 switch(dmisc5)
15694 {
15695 // Center eye shoots projectiles; make room for its firing tiles
15696 case 1:
15697 case 3:
15698 144 ((enemy*)guys.spr(i))->o_tile=d->e_tile+120;
15699 144 break;
15700
15701 // Center eyes does not shoot; use tiles two rows below for inner eyes.
15702 default:
15703 case 2:
15704 168 ((enemy*)guys.spr(i))->o_tile=d->e_tile+40;
15705 168 break;
15706 }
15707 312 }
15708 else ((enemy*)guys.spr(i))->o_tile = d->s_tile;
15709 312 }
15710 else
15711 {
15712 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
15713 }
15714
15715 312 ((enemy*)guys.spr(i))->cs=dmisc9;
15716
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if (dmisc27) ((enemy*)guys.spr(i))->hp=dmisc27;
15717 312 }
15718
15719
2/2
✓ Branch 0 taken 263816 times.
✓ Branch 1 taken 70613 times.
334429 if(flycnt>0)
15720 {
15721 263816 ((enemy*)guys.spr(i))->superman=true;
15722 263816 }
15723 else
15724 {
15725 70613 ((enemy*)guys.spr(i))->superman=false;
15726 }
15727
15728
2/2
✓ Branch 0 taken 145 times.
✓ Branch 1 taken 334284 times.
334429 if(((enemy*)guys.spr(i))->hp <= 0)
15729 {
15730
2/2
✓ Branch 0 taken 269 times.
✓ Branch 1 taken 145 times.
414 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
15731 {
15732 269 guys.swap(j,j+1);
15733 269 }
15734
15735
3/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 127 times.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
145 if (--flycnt2 == 0 && dmisc24 != 0) step += zslongToFix(dmisc24*100);
15736 145 }
15737 else
15738 {
15739 334284 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
15740
1/2
✓ Branch 0 taken 334284 times.
✗ Branch 1 not taken.
334284 double a2 = ((clk2-pos2*basesize/(dmisc2==0 ? 1 : dmisc2))*PI/(halfsize));
15741
15742
2/2
✓ Branch 0 taken 7259 times.
✓ Branch 1 taken 327025 times.
334284 if(dmisc4==0)
15743 {
15744
2/2
✓ Branch 0 taken 168378 times.
✓ Branch 1 taken 158647 times.
327025 if(loopcnt>0)
15745 {
15746
1/2
✓ Branch 0 taken 168378 times.
✗ Branch 1 not taken.
168378 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc32) - zc::math::Sin(pos2*PI*2/(dmisc2==0?1:dmisc2))*((int64_t)abs(dmisc32)-abs(dmisc30));
15747
1/2
✓ Branch 0 taken 168378 times.
✗ Branch 1 not taken.
168378 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc32) + zc::math::Cos(pos2*PI*2/(dmisc2==0?1:dmisc2))*((int64_t)abs(dmisc32)-abs(dmisc30));
15748 168378 }
15749 else
15750 {
15751 158647 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
15752 158647 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc30);
15753 }
15754
15755 327025 temp_x=guys.spr(i)->x;
15756 327025 temp_y=guys.spr(i)->y;
15757 327025 }
15758 else
15759 {
15760 7259 circle_x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
15761 7259 circle_y = -zc::math::Sin(a2+PI/2)*abs(dmisc30);
15762
15763
2/2
✓ Branch 0 taken 3965 times.
✓ Branch 1 taken 3294 times.
7259 if(loopcnt>0)
15764 {
15765 3965 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
15766
1/2
✓ Branch 0 taken 3965 times.
✗ Branch 1 not taken.
3965 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc2 == 0 ? 1 : dmisc2)))*abs(dmisc32);
15767 3965 }
15768 else
15769 {
15770 3294 guys.spr(i)->x = circle_x;
15771 3294 guys.spr(i)->y = circle_y;
15772 }
15773
15774 7259 temp_x=circle_x;
15775 7259 temp_y=circle_y;
15776 }
15777
15778 double _MSVC2022_tmp1, _MSVC2022_tmp2;
15779 334284 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
15780
15781
4/4
✓ Branch 0 taken 61619 times.
✓ Branch 1 taken 272665 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41746 times.
334284 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
15782 {
15783 41746 guys.spr(i)->dir=l_down;
15784 41746 }
15785
4/4
✓ Branch 0 taken 61607 times.
✓ Branch 1 taken 230931 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41734 times.
292538 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
15786 {
15787 41734 guys.spr(i)->dir=left;
15788 41734 }
15789
4/4
✓ Branch 0 taken 61615 times.
✓ Branch 1 taken 189189 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41742 times.
250804 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
15790 {
15791 41742 guys.spr(i)->dir=l_up;
15792 41742 }
15793
4/4
✓ Branch 0 taken 61631 times.
✓ Branch 1 taken 147431 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41758 times.
209062 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
15794 {
15795 41758 guys.spr(i)->dir=up;
15796 41758 }
15797
4/4
✓ Branch 0 taken 61703 times.
✓ Branch 1 taken 105601 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41830 times.
167304 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
15798 {
15799 41830 guys.spr(i)->dir=r_up;
15800 41830 }
15801
4/4
✓ Branch 0 taken 61697 times.
✓ Branch 1 taken 63777 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41824 times.
125474 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
15802 {
15803 41824 guys.spr(i)->dir=right;
15804 41824 }
15805
4/4
✓ Branch 0 taken 61725 times.
✓ Branch 1 taken 21925 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41852 times.
83650 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
15806 {
15807 41852 guys.spr(i)->dir=r_down;
15808 41852 }
15809 else
15810 {
15811 41798 guys.spr(i)->dir=down;
15812 }
15813
15814 334284 guys.spr(i)->x += x;
15815 334284 guys.spr(i)->y = y-guys.spr(i)->y;
15816
15817
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 334284 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 189016 times.
✓ Branch 5 taken 145268 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 189016 times.
334284 if((wpn>wEnemyWeapons || (wpn >= wScript1 && wpn <= wScript10)) && (dmisc5==2 || dmisc5== 3))
15818 {
15819 /*
15820 if(!(zc_oldrand()&127))
15821 {
15822 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID());
15823 sfx(wpnsfx(wpn),pan(x));
15824 }
15825 */
15826
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 145268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
145268 if (((esPatra*)guys.spr(i))->clk5 < 0 && (editorflags & ENEMY_FLAG3))
15827 {
15828 if (((esPatra*)guys.spr(i))->clk4 <= 0 || ((esPatra*)guys.spr(i))->clk5 != -16) ++((esPatra*)guys.spr(i))->clk5;
15829 if (get_qr(qr_PATRAS_USE_HARDCODED_OFFSETS))
15830 {
15831 if (dmisc5 == 3)
15832 {
15833 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
15834 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+200;
15835 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+160;
15836 else ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
15837 }
15838 else
15839 {
15840 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+40;
15841 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
15842 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+80;
15843 else ((esPatra*)guys.spr(i))->o_tile=d->e_tile+40;
15844 }
15845 }
15846 else
15847 {
15848 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->s_tile;
15849 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->s_tile+80;
15850 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->s_tile+40;
15851 else ((esPatra*)guys.spr(i))->o_tile=d->s_tile;
15852 }
15853 }
15854
4/6
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 145268 times.
✓ Branch 4 taken 145268 times.
✓ Branch 5 taken 145268 times.
145268 else if ((dmisc19 || ((esPatra*)guys.spr(i))->clk5) && (((esPatra*)guys.spr(i))->clk4 <= 0 || ((esPatra*)guys.spr(i))->clk5 != -16)) ++((esPatra*)guys.spr(i))->clk5;
15855
1/2
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
145268 if (((esPatra*)guys.spr(i))->clk4 > 0) --((esPatra*)guys.spr(i))->clk4;
15856
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 145268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
145268 if (!dmisc25 || (dmisc25 == 1 && !((enemy*)guys.spr(i))->superman) || ((dmisc25 == 2 || dmisc25 == 3) && ((enemy*)guys.spr(i))->superman))
15857 {
15858
1/5
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
145268 switch(dmisc20) //Patra Attack Patterns
15859 {
15860 case 4: //Single one rapidfires
15861 {
15862 if (dofire && i == randeye)
15863 {
15864 ((esPatra*)guys.spr(i))->clk5 = -16;
15865 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) ((esPatra*)guys.spr(i))->clk5 = -48;
15866 ((esPatra*)guys.spr(i))->clk4 = 96;
15867 clk5 = -3;
15868 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk5) + 16;
15869 }
15870 if (((esPatra*)guys.spr(i))->clk5 == -16 && (((esPatra*)guys.spr(i))->clk4 % 12) == 0)
15871 {
15872 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15873 sfx(wpnsfx(wpn),pan(x));
15874 }
15875 break;
15876 }
15877 case 3: //Ring
15878 {
15879 if (dofire)
15880 {
15881 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
15882 {
15883 ((esPatra*)guys.spr(i))->clk5 = -48;
15884 clk5 = -48;
15885 if (editorflags & ENEMY_FLAG6) clk4 = 64;
15886 }
15887 else
15888 {
15889 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15890 sfx(wpnsfx(wpn),pan(x));
15891 int32_t m=Ewpns.Count()-1;
15892 weapon *ew = (weapon*)(Ewpns.spr(m));
15893
15894 ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
15895 ((esPatra*)guys.spr(i))->clk5 = 0;
15896 clk5 = 0;
15897 if (editorflags & ENEMY_FLAG6) clk4 = 16;
15898 }
15899 }
15900 if (((esPatra*)guys.spr(i))->clk5 == -16)
15901 {
15902 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15903 sfx(wpnsfx(wpn),pan(x));
15904 int32_t m=Ewpns.Count()-1;
15905 weapon *ew = (weapon*)(Ewpns.spr(m));
15906
15907 ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
15908 }
15909 break;
15910 }
15911 case 2: //one after another
15912 {
15913 if (dofire)
15914 {
15915 ((esPatra*)guys.spr(i))->clk5 = -48 - (12*(i-(index+flycnt+1)));
15916 clk5 = -48 - (12*flycnt2);
15917 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk5) + 16;
15918 }
15919 if (((esPatra*)guys.spr(i))->clk5 == -16)
15920 {
15921 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15922 sfx(wpnsfx(wpn),pan(x));
15923 }
15924 break;
15925 }
15926 case 1: //random one eye
15927 {
15928 if (dofire && i == randeye)
15929 {
15930 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
15931 {
15932 ((esPatra*)guys.spr(i))->clk5 = -48;
15933 clk5 = -48;
15934 if (editorflags & ENEMY_FLAG6) clk4 = 64;
15935 }
15936 else
15937 {
15938 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15939 sfx(wpnsfx(wpn),pan(x));
15940 ((esPatra*)guys.spr(i))->clk5 = 0;
15941 clk5 = 0;
15942 if (editorflags & ENEMY_FLAG6) clk4 = 16;
15943 }
15944 }
15945 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && ((esPatra*)guys.spr(i))->clk5 == -16)
15946 {
15947 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15948 sfx(wpnsfx(wpn),pan(x));
15949 }
15950 break;
15951 }
15952 default: //old behavior, all eyes can fire any time
15953 {
15954
3/8
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1155 times.
✓ Branch 5 taken 1155 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
145268 if ((((dmisc18 && !(zc_oldrand() % zc_max(dmisc18, 1))) ||
15955
3/6
✓ Branch 0 taken 145268 times.
✓ Branch 1 taken 1155 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1155 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
147578 (!dmisc18 && !(zc_oldrand()&127))) && (((esPatra*)guys.spr(i))->clk5 >= 0 || !(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
15956
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1155 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1155 && ((esPatra*)guys.spr(i))->clk5 >= dmisc19) && (!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 &&
15957 (dmisc20 != 2 && (basesize*((int64_t)dmisc6 - zc::math::SafeMod(misc, dmisc6))) > 48))))
15958 {
15959
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1155 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1155 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
15960 {
15961 ((esPatra*)guys.spr(i))->clk5 = -48;
15962 if (editorflags & ENEMY_FLAG6) clk4 = 64;
15963 }
15964 else
15965 {
15966 1155 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, fakez);
15967 1155 sfx(wpnsfx(wpn),pan(x));
15968 1155 ((esPatra*)guys.spr(i))->clk5 = 0;
15969
1/2
✓ Branch 0 taken 1155 times.
✗ Branch 1 not taken.
1155 if (editorflags & ENEMY_FLAG6) clk4 = 16;
15970 }
15971 1155 }
15972
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 145268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
147578 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && ((esPatra*)guys.spr(i))->clk5 == -16)
15973 {
15974 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, fakez);
15975 sfx(wpnsfx(wpn),pan(x));
15976 }
15977 145268 break;
15978 }
15979 }
15980 145268 }
15981 145268 }
15982
15983 }
15984 334429 }
15985 46240 }
15986
15987 160441 adjusted=true;
15988 160441 return enemy::animate(index);
15989 161885 }
15990
15991 249 void ePatra::FirePatraWeapon()
15992 { //.707
15993 249 int32_t xoff = 0;
15994 249 int32_t yoff = 0;
15995
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (SIZEflags & OVERRIDE_HIT_WIDTH)
15996 {
15997 xoff += hxofs;
15998 if (weap_data.override_flags & OVERRIDE_HIT_WIDTH)
15999 xoff += (hit_width / 2) - (weap_data.tilew * 8);
16000 else
16001 xoff += (hit_width / 2) - 8;
16002 }
16003
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (SIZEflags & OVERRIDE_HIT_HEIGHT)
16004 {
16005 yoff += hyofs;
16006 if (weap_data.override_flags & OVERRIDE_HIT_HEIGHT)
16007 yoff += (hit_height / 2) - (weap_data.tileh * 8);
16008 else
16009 yoff += (hit_height / 2) - 8;
16010 }
16011 249 sfx(wpnsfx(wpn),pan(x));
16012 // TODO(crash): check that .add succeeds.
16013
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 249 times.
249 switch (dmisc28)
16014 {
16015 case patrat8SHOT: //Fire Wizzrobe
16016 case patrat4SHOTDIAG:
16017 case patrat4SHOTRAND:
16018 if (dmisc28 != patrat4SHOTRAND || (zc_oldrand()%2)) //if it's the 4 shot rand type, only let it through half the time. Break is within so it doesn't do both, but if it skips this one it'll always do the other one.
16019 {
16020 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,l_up,-1, getUID(),false));
16021 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16022 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16023 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16024
16025 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,l_down,-1, getUID(),false));
16026 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16027 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16028 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16029
16030 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,r_up,-1, getUID(),false));
16031 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16032 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16033 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16034
16035 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,r_down,-1, getUID(),false));
16036 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16037 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16038 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16039
16040 if (dmisc28 == patrat4SHOTDIAG || dmisc28 == patrat4SHOTRAND) break;
16041 }
16042
16043 [[fallthrough]];
16044 case patrat4SHOTCARD: //Stalfos 3
16045 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,up,-1, getUID(),false));
16046 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16047 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16048 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,down,-1, getUID(),false));
16049 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16050 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16051 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,left,-1, getUID(),false));
16052 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16053 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16054 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,right,-1, getUID(),false));
16055 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16056 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16057 break;
16058
16059 default:
16060 249 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16061
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (dmisc28 == patratBREATH) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle += (zc_rand(20,-20)/100.0)*PI;
16062 249 double anglestore = ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle;
16063
3/6
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 249 times.
249 if (dmisc28 == patrat1SHOTFAST || dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16064
4/8
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 249 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 249 times.
249 if (dmisc28 == patrat3SHOT || dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOT || dmisc28 == patrat5SHOTFAST)
16065 {
16066 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16067 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore + (double)0.46364761;
16068 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.1180;
16069 if (dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16070 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16071 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore - (double)0.46364761;
16072 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.1180;
16073 if (dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16074 if (dmisc28 == patrat5SHOT || dmisc28 == patrat5SHOTFAST)
16075 {
16076 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16077 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore + (double)0.78539816;
16078 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.4142;
16079 if (dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16080 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16081 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore - (double)0.78539816;
16082 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.4142;
16083 if (dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16084 }
16085 }
16086 249 break;
16087
16088 }
16089 249 sfx(wpnsfx(wpn),pan(x));
16090 //+0.46364761
16091 //11.80
16092 249 }
16093
16094 324242 void ePatra::draw(BITMAP *dest)
16095 {
16096 324242 tile=o_tile;
16097 324242 update_enemy_frame();
16098 324242 enemy::draw(dest);
16099 324242 }
16100
16101 int32_t ePatra::defend(int32_t wpnId, int32_t *power, int32_t edef)
16102 {
16103 int32_t ret = enemy::defend(wpnId, power, edef);
16104
16105 if(ret < 0 && (flycnt||flycnt2))
16106 return 0;
16107
16108 return ret;
16109 }
16110
16111 1733 int32_t ePatra::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable)
16112 {
16113 1733 int32_t ret = enemy::defendNew(wpnId, power, edef, unblockable);
16114
16115
6/6
✓ Branch 0 taken 1613 times.
✓ Branch 1 taken 120 times.
✓ Branch 2 taken 779 times.
✓ Branch 3 taken 834 times.
✓ Branch 4 taken 447 times.
✓ Branch 5 taken 332 times.
1733 if(ret < 0 && (flycnt||flycnt2))
16116 1281 return 0;
16117
16118 452 return ret;
16119 1733 }
16120
16121 190 void ePatra::init_size_flags() {
16122 190 SIZEflags = d->SIZEflags;
16123
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
190 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && txsz > 0) { txsz = txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16124
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) { txsz = 2; extend = 3; }
16125 // al_trace("Enemy txsz:%i\n", txsz);
16126
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
190 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && tysz > 0) { tysz = tysz; if (tysz > 1) extend = 3; }
16127
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) { tysz = 2; extend = 3; }
16128
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
190 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0) hit_width = hit_width;
16129
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) hit_width = 32;
16130
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
190 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0) hit_height = hit_height;
16131
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
190 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0) hzsz = hzsz;
16132
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = hxofs;
16133
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) hxofs = -8;
16134
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = hyofs;
16135 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16136
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)xofs;
16137
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) xofs = -8;
16138
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
16139 {
16140 yofs = (int32_t)yofs; //This seems to be setting to +48 or something with any value set?! -Z
16141 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
16142 }
16143
1/4
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
190 else if (dmisc10 == 1) yofs = (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset) - 8;
16144
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if (editorflags & ENEMY_FLAG8) misc = 1;
16145
16146
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)zofs;
16147
16148 190 }
16149
16150 1656 esPatra::esPatra(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk)
16151 1656 {
16152 //cs=8;
16153
1/2
✓ Branch 0 taken 1656 times.
✗ Branch 1 not taken.
1656 setParent(prnt);
16154 1656 item_set=0;
16155 1656 misc=clk;
16156 1656 clk4 = 0;
16157 1656 clk5 = 0;
16158 1656 clk = -((misc*21)>>1)-1;
16159
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1656 times.
✓ Branch 2 taken 1656 times.
✗ Branch 3 not taken.
1656 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
16160 1656 hit_width=12;
16161 1656 hit_height=12;
16162 1656 hxofs=2;
16163 1656 hyofs=2;
16164 1656 extend = 0;
16165 1656 txsz = 1;
16166 1656 tysz = 1;
16167 /* //These need to be separate enemy editor fields. This enemy class also its draw altered to correctly support big stuff.
16168 enemy *prntenemy = (enemy *) guys.getByUID(parent->getUID());
16169 int32_t prntSIZEflags = prntenemy->SIZEflags;
16170 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = prntenemy->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16171 // al_trace("Enemy txsz:%i\n", txsz);
16172 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = prntenemy->tysz; if ( tysz > 1 ) extend = 3; }
16173 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = prntenemy->hxsz;
16174 else
16175 hxsz=12;
16176 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = prntenemy->hysz;
16177 else
16178 hysz=12;
16179 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = prntenemy->hzsz;
16180 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = prntenemy->hxofs;
16181 else
16182 hxofs=2;
16183 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = prntenemy->hyofs;
16184 else hyofs=2;
16185 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16186 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)prntenemy->xofs;
16187 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
16188 {
16189 yofs = (int32_t)prntenemy->yofs; //This seems to be setting to +48 or something with any value set?! -Z
16190 }
16191
16192 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)prntenemy->zofs;
16193 */
16194 1656 mainguy=count_enemy=false;
16195 1656 bgsfx=-1;
16196 //o_tile=0;
16197
2/4
✓ Branch 0 taken 1656 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1656 times.
✗ Branch 3 not taken.
1656 flags &= (~guy_never_return);
16198 1656 deadsfx = WAV_EDEAD;
16199 1656 hitsfx = WAV_EHIT;
16200 1656 isCore = false;
16201 1656 }
16202
16203 1010584 bool esPatra::animate(int32_t index)
16204 {
16205
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1010584 times.
1010584 if(switch_hooked) return enemy::animate(index);
16206
2/2
✓ Branch 0 taken 15160 times.
✓ Branch 1 taken 995424 times.
1010584 if(dying)
16207 15160 return Dead(index);
16208
16209 995424 return enemy::animate(index);
16210 1010584 }
16211
16212 2028196 void esPatra::draw(BITMAP *dest)
16213 {
16214
2/2
✓ Branch 0 taken 1721294 times.
✓ Branch 1 taken 306902 times.
2028196 if(get_qr(qr_NEWENEMYTILES))
16215 {
16216 1721294 tile = o_tile+(clk&3);
16217
16218
8/9
✓ Branch 0 taken 214278 times.
✓ Branch 1 taken 217924 times.
✓ Branch 2 taken 215346 times.
✓ Branch 3 taken 215726 times.
✓ Branch 4 taken 213062 times.
✓ Branch 5 taken 214350 times.
✓ Branch 6 taken 215734 times.
✓ Branch 7 taken 214874 times.
✗ Branch 8 not taken.
1721294 switch(dir) //directions get screwed up after 8. *shrug*
16219 {
16220 case up: //u
16221 214278 flip=0;
16222 214278 break;
16223
16224 case down: //d
16225 217924 flip=0;
16226 217924 tile+=4;
16227 217924 break;
16228
16229 case left: //l
16230 215346 flip=0;
16231 215346 tile+=8;
16232 215346 break;
16233
16234 case right: //r
16235 215726 flip=0;
16236 215726 tile+=12;
16237 215726 break;
16238
16239 case l_up: //ul
16240 213062 flip=0;
16241 213062 tile+=20;
16242 213062 break;
16243
16244 case r_up: //ur
16245 214350 flip=0;
16246 214350 tile+=24;
16247 214350 break;
16248
16249 case l_down: //dl
16250 215734 flip=0;
16251 215734 tile+=28;
16252 215734 break;
16253
16254 case r_down: //dr
16255 214874 flip=0;
16256 214874 tile+=32;
16257 214874 break;
16258 }
16259 1721294 }
16260 else
16261 {
16262 306902 tile = o_tile+((clk&2)>>1);
16263 }
16264
16265
2/2
✓ Branch 0 taken 114856 times.
✓ Branch 1 taken 1913340 times.
2028196 if(clk>=0)
16266 1913340 enemy::draw(dest);
16267 2028196 }
16268
16269
16270 102 ePatraBS::ePatraBS(zfix ,zfix ,int32_t Id,int32_t Clk) : enemy((zfix)128,(zfix)48,Id,Clk)
16271 102 {
16272 102 adjusted=false;
16273
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 dir=(zc_oldrand()&7)+8;
16274
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 step=0.25;
16275 102 clk4 = 0;
16276 102 clk5 = 0;
16277 //flycnt=6; flycnt2=0;
16278 102 flycnt=dmisc1;
16279 102 flycnt2=0; // PatraBS doesn't have inner rings!
16280 102 loopcnt=0;
16281
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 init_size_flags();
16282
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 if(dmisc6<int16_t(1))dmisc6=1; // ratio cannot be 0!
16283
16284 //nets+4480;
16285 102 }
16286
16287 35963 bool ePatraBS::animate(int32_t index)
16288 {
16289
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35963 times.
35963 if(switch_hooked) return enemy::animate(index);
16290
2/2
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 35723 times.
35963 if(dying)
16291 240 return Dead(index);
16292
16293
2/2
✓ Branch 0 taken 31705 times.
✓ Branch 1 taken 4018 times.
35723 if(clk==0)
16294 {
16295 4018 removearmos(x,y);
16296 4018 }
16297
16298 35723 variable_walk_8(rate,homing,hrate,spw_floater);
16299
16300
2/2
✓ Branch 0 taken 35387 times.
✓ Branch 1 taken 336 times.
35723 if(++clk2>90)
16301 {
16302 336 clk2=0;
16303
16304
2/2
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 159 times.
336 if(loopcnt)
16305 177 --loopcnt;
16306 else
16307 {
16308
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 75 times.
159 if(zc::math::SafeMod(misc, dmisc6)==0)
16309 84 loopcnt=dmisc7;
16310 }
16311
16312 336 ++misc;
16313 336 }
16314
16315 // double size=1;;
16316
2/2
✓ Branch 0 taken 153472 times.
✓ Branch 1 taken 35723 times.
189195 for(int32_t i=index+1; i<index+flycnt+1; i++)
16317 {
16318
2/2
✓ Branch 0 taken 152860 times.
✓ Branch 1 taken 612 times.
153472 if(!adjusted)
16319 {
16320 612 ((enemy*)guys.spr(i))->hp=dmisc3;
16321
16322
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(get_qr(qr_NEWENEMYTILES))
16323 {
16324 612 ((enemy*)guys.spr(i))->o_tile=o_tile+dmisc8;
16325 612 }
16326 else
16327 {
16328 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
16329 }
16330
16331 612 ((enemy*)guys.spr(i))->cs = dmisc9;
16332 612 }
16333
16334
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 153368 times.
153472 if(((enemy*)guys.spr(i))->hp <= 0)
16335 {
16336
2/2
✓ Branch 0 taken 131 times.
✓ Branch 1 taken 104 times.
235 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
16337 {
16338 131 guys.swap(j,j+1);
16339 131 }
16340
16341 104 --flycnt;
16342 104 }
16343 else
16344 {
16345 153368 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
16346
1/2
✓ Branch 0 taken 153368 times.
✗ Branch 1 not taken.
153368 double a2 = ((int64_t)clk2-pos2*90/(dmisc1==0?1:dmisc1))*PI/45;
16347 153368 temp_x = zc::math::Cos(a2+PI/2)*45;
16348 153368 temp_y = -zc::math::Sin(a2+PI/2)*45;
16349
16350
2/2
✓ Branch 0 taken 77643 times.
✓ Branch 1 taken 75725 times.
153368 if(loopcnt>0)
16351 {
16352 77643 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*45;
16353
1/2
✓ Branch 0 taken 77643 times.
✗ Branch 1 not taken.
77643 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc1==0?1:dmisc1)))*22.5;
16354 77643 }
16355 else
16356 {
16357 75725 guys.spr(i)->x = temp_x;
16358 75725 guys.spr(i)->y = temp_y;
16359 }
16360
16361 double _MSVC2022_tmp1, _MSVC2022_tmp2;
16362 153368 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
16363
16364
4/4
✓ Branch 0 taken 29178 times.
✓ Branch 1 taken 124190 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18812 times.
153368 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
16365 {
16366 18812 guys.spr(i)->dir=l_down;
16367 18812 }
16368
4/4
✓ Branch 0 taken 29205 times.
✓ Branch 1 taken 105351 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18839 times.
134556 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
16369 {
16370 18839 guys.spr(i)->dir=left;
16371 18839 }
16372
4/4
✓ Branch 0 taken 29168 times.
✓ Branch 1 taken 86549 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18802 times.
115717 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
16373 {
16374 18802 guys.spr(i)->dir=l_up;
16375 18802 }
16376
4/4
✓ Branch 0 taken 30509 times.
✓ Branch 1 taken 66406 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 20143 times.
96915 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
16377 {
16378 20143 guys.spr(i)->dir=up;
16379 20143 }
16380
4/4
✓ Branch 0 taken 28883 times.
✓ Branch 1 taken 47889 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18517 times.
76772 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
16381 {
16382 18517 guys.spr(i)->dir=r_up;
16383 18517 }
16384
4/4
✓ Branch 0 taken 29145 times.
✓ Branch 1 taken 29110 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18779 times.
58255 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
16385 {
16386 18779 guys.spr(i)->dir=right;
16387 18779 }
16388
4/4
✓ Branch 0 taken 29358 times.
✓ Branch 1 taken 10118 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18992 times.
39476 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
16389 {
16390 18992 guys.spr(i)->dir=r_down;
16391 18992 }
16392 else
16393 {
16394 20484 guys.spr(i)->dir=down;
16395 }
16396
16397 153368 guys.spr(i)->x += x;
16398 153368 guys.spr(i)->y += y;
16399 }
16400 153472 }
16401
16402 35723 adjusted=true;
16403 35723 return enemy::animate(index);
16404 35963 }
16405
16406 72874 void ePatraBS::draw(BITMAP *dest)
16407 {
16408 72874 tile=o_tile;
16409
16410
1/2
✓ Branch 0 taken 72874 times.
✗ Branch 1 not taken.
72874 if(get_qr(qr_NEWENEMYTILES))
16411 {
16412 double _MSVC2022_tmp1, _MSVC2022_tmp2;
16413 72874 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
16414
16415
4/4
✓ Branch 0 taken 27164 times.
✓ Branch 1 taken 45710 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 19146 times.
72874 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
16416 {
16417 19146 lookat=l_down;
16418 19146 }
16419
4/4
✓ Branch 0 taken 26316 times.
✓ Branch 1 taken 27412 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 18298 times.
53728 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
16420 {
16421 18298 lookat=down;
16422 18298 }
16423
4/4
✓ Branch 0 taken 21642 times.
✓ Branch 1 taken 13788 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 13624 times.
35430 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
16424 {
16425 13624 lookat=r_down;
16426 13624 }
16427
4/4
✓ Branch 0 taken 15510 times.
✓ Branch 1 taken 6296 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 7492 times.
21806 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
16428 {
16429 7492 lookat=right;
16430 7492 }
16431
4/4
✓ Branch 0 taken 9188 times.
✓ Branch 1 taken 5126 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 1170 times.
14314 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
16432 {
16433 1170 lookat=r_up;
16434 1170 }
16435
4/4
✓ Branch 0 taken 8982 times.
✓ Branch 1 taken 4162 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 964 times.
13144 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
16436 {
16437 964 lookat=up;
16438 964 }
16439
4/4
✓ Branch 0 taken 9718 times.
✓ Branch 1 taken 2462 times.
✓ Branch 2 taken 1700 times.
✓ Branch 3 taken 8018 times.
12180 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
16440 {
16441 1700 lookat=l_up;
16442 1700 }
16443 else
16444 {
16445 10480 lookat=left;
16446 }
16447
16448
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 964 times.
✓ Branch 2 taken 18298 times.
✓ Branch 3 taken 10480 times.
✓ Branch 4 taken 7492 times.
✓ Branch 5 taken 1700 times.
✓ Branch 6 taken 1170 times.
✓ Branch 7 taken 19146 times.
✓ Branch 8 taken 13624 times.
72874 switch(lookat) //directions get screwed up after 8. *shrug*
16449 {
16450 case up: //u
16451 964 flip=0;
16452 964 break;
16453
16454 case down: //d
16455 18298 flip=0;
16456 18298 tile+=8;
16457 18298 break;
16458
16459 case left: //l
16460 10480 flip=0;
16461 10480 tile+=40;
16462 10480 break;
16463
16464 case right: //r
16465 7492 flip=0;
16466 7492 tile+=48;
16467 7492 break;
16468
16469 case l_up: //ul
16470 1700 flip=0;
16471 1700 tile+=80;
16472 1700 break;
16473
16474 case r_up: //ur
16475 1170 flip=0;
16476 1170 tile+=88;
16477 1170 break;
16478
16479 case l_down: //dl
16480 19146 flip=0;
16481 19146 tile+=120;
16482 19146 break;
16483
16484 case r_down: //dr
16485 13624 flip=0;
16486 13624 tile+=128;
16487 13624 break;
16488 }
16489
16490 72874 tile+=(2*(clk&3));
16491 72874 xofs-=8;
16492 72874 yofs-=8;
16493 72874 drawblock(dest,15);
16494 72874 xofs+=8;
16495 72874 yofs+=8;
16496 72874 }
16497 else
16498 {
16499 flip=(clk&1);
16500 xofs-=8;
16501 yofs-=8;
16502 enemy::draw(dest);
16503 xofs+=16;
16504 enemy::draw(dest);
16505 yofs+=16;
16506 enemy::draw(dest);
16507 xofs-=16;
16508 enemy::draw(dest);
16509 xofs+=8;
16510 yofs-=8;
16511 }
16512 72874 }
16513
16514 int32_t ePatraBS::defend(int32_t wpnId, int32_t *power, int32_t edef)
16515 {
16516 int32_t ret = enemy::defend(wpnId, power, edef);
16517
16518 if(ret < 0 && (flycnt||flycnt2))
16519 return 0;
16520
16521 return ret;
16522 }
16523
16524 142 int32_t ePatraBS::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable)
16525 {
16526 142 int32_t ret = enemy::defendNew(wpnId, power, edef, unblockable);
16527
16528
5/6
✓ Branch 0 taken 141 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 60 times.
✓ Branch 3 taken 81 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 60 times.
142 if(ret < 0 && (flycnt||flycnt2))
16529 81 return 0;
16530
16531 61 return ret;
16532 142 }
16533
16534 102 void ePatraBS::init_size_flags()
16535 {
16536 102 SIZEflags = d->SIZEflags;
16537
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
102 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16538 // al_trace("Enemy txsz:%i\n", txsz);
16539
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
102 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
16540
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
102 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0) hit_width = d->hxsz;
16541 102 else hit_width = 32;
16542
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
102 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0) hit_height = d->hysz;
16543
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
102 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0) hzsz = d->hzsz;
16544
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
16545 102 else hxofs = -8;
16546
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
16547 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16548
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
16549
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
16550 {
16551 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
16552 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
16553 }
16554
16555
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
16556 102 }
16557
16558 612 esPatraBS::esPatraBS(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk)
16559 612 {
16560 //cs=csBOSS;
16561
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 setParent(prnt);
16562 612 item_set=0;
16563 612 misc=clk;
16564 612 clk = -((misc*21)>>1)-1;
16565 612 clk4 = 0;
16566 612 clk5 = 0;
16567
2/4
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 612 times.
✗ Branch 3 not taken.
612 enemy *prntenemy = (enemy *) guys.getByUID(parent->getUID());
16568 612 int32_t prntSIZEflags = prntenemy->SIZEflags;
16569
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = prntenemy->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16570 // al_trace("Enemy txsz:%i\n", txsz);
16571
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = prntenemy->tysz; if ( tysz > 1 ) extend = 3; }
16572
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = prntenemy->hit_width;
16573 612 else hit_width=16;
16574
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = prntenemy->hit_height;
16575 612 else hit_height=16;
16576
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = prntenemy->hzsz;
16577
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if ( (prntSIZEflags&OVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = prntenemy->hxofs;
16578
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
612 if ( (prntSIZEflags&OVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = prntenemy->hyofs;
16579 612 else hyofs=2;
16580 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16581
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( (prntSIZEflags&OVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)prntenemy->xofs;
16582
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
612 if ( (prntSIZEflags&OVERRIDE_DRAW_Y_OFFSET) != 0 )
16583 {
16584 yofs = (int32_t)prntenemy->yofs;
16585 }
16586
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✓ Branch 2 taken 612 times.
✗ Branch 3 not taken.
612 else yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
16587
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( (prntSIZEflags&OVERRIDE_DRAW_Z_OFFSET) != 0 ) prntenemy->zofs = (int32_t)zofs;
16588
16589 612 bgsfx=-1;
16590 612 mainguy=count_enemy=false;
16591 612 deadsfx = WAV_EDEAD;
16592 612 hitsfx = WAV_EHIT;
16593
2/4
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 612 times.
✗ Branch 3 not taken.
612 flags &= ~guy_never_return;
16594 612 isCore = false;
16595 612 }
16596
16597 155090 bool esPatraBS::animate(int32_t index)
16598 {
16599
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 155090 times.
155090 if(switch_hooked) return enemy::animate(index);
16600
2/2
✓ Branch 0 taken 1552 times.
✓ Branch 1 taken 153538 times.
155090 if(dying)
16601 1552 return Dead(index);
16602
16603 153538 return enemy::animate(index);
16604 155090 }
16605
16606 315868 void esPatraBS::draw(BITMAP *dest)
16607 {
16608 315868 tile=o_tile;
16609
16610
1/2
✓ Branch 0 taken 315868 times.
✗ Branch 1 not taken.
315868 if(get_qr(qr_NEWENEMYTILES))
16611 {
16612
8/9
✓ Branch 0 taken 41612 times.
✓ Branch 1 taken 42622 times.
✓ Branch 2 taken 37916 times.
✓ Branch 3 taken 38458 times.
✓ Branch 4 taken 38564 times.
✓ Branch 5 taken 38568 times.
✓ Branch 6 taken 38662 times.
✓ Branch 7 taken 39466 times.
✗ Branch 8 not taken.
315868 switch(dir) //directions get screwed up after 8. *shrug*
16613 {
16614 case up: //u
16615 41612 flip=0;
16616 41612 break;
16617
16618 case down: //d
16619 42622 flip=0;
16620 42622 tile+=4;
16621 42622 break;
16622
16623 case left: //l
16624 37916 flip=0;
16625 37916 tile+=8;
16626 37916 break;
16627
16628 case right: //r
16629 38458 flip=0;
16630 38458 tile+=12;
16631 38458 break;
16632
16633 case l_up: //ul
16634 38564 flip=0;
16635 38564 tile+=20;
16636 38564 break;
16637
16638 case r_up: //ur
16639 38568 flip=0;
16640 38568 tile+=24;
16641 38568 break;
16642
16643 case l_down: //dl
16644 38662 flip=0;
16645 38662 tile+=28;
16646 38662 break;
16647
16648 case r_down: //dr
16649 39466 flip=0;
16650 39466 tile+=32;
16651 39466 break;
16652 }
16653
16654 315868 tile += ((clk&6)>>1);
16655 315868 }
16656 else
16657 {
16658 tile += (clk&4)?1:0;
16659 }
16660
16661
2/2
✓ Branch 0 taken 32116 times.
✓ Branch 1 taken 283752 times.
315868 if(clk>=0)
16662 283752 enemy::draw(dest);
16663 315868 }
16664
16665 351473 void addEwpn(int32_t x,int32_t y,int32_t z,int32_t id,int32_t type,int32_t power,int32_t dir, int32_t parentid, byte script_generated, int32_t fakez)
16666 {
16667
4/6
✓ Branch 0 taken 242582 times.
✓ Branch 1 taken 108891 times.
✓ Branch 2 taken 242582 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 242582 times.
✗ Branch 5 not taken.
351473 if(id>wEnemyWeapons || (id >= wScript1 && id <= wScript10))
16668
4/8
✓ Branch 0 taken 351473 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351473 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 351473 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 351473 times.
✗ Branch 7 not taken.
351473 Ewpns.add(new weapon((zfix)x,(zfix)y,(zfix)z,id,type,power,dir, -1, parentid, script_generated));
16669
1/2
✓ Branch 0 taken 351473 times.
✗ Branch 1 not taken.
351473 if (fakez > 0) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16670 351473 }
16671
16672 77344 int32_t hit_enemy(int32_t index, int32_t wpnId,int32_t power,int32_t wpnx,int32_t wpny,int32_t dir, int32_t enemyHitWeapon, weapon* realweap)
16673 {
16674 // Kludge
16675
4/8
✓ Branch 0 taken 77344 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77344 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 77344 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 77344 times.
✗ Branch 7 not taken.
77344 weapon *w = new weapon((zfix)wpnx,(zfix)wpny,(zfix)0,wpnId,0,power,dir,enemyHitWeapon,-1,false);
16676 77344 int32_t ret = ((enemy*)guys.spr(index))->takehit(w,realweap);
16677
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77344 times.
77344 delete w;
16678 77344 return ret;
16679 }
16680
16681 9565 void enemy_scored(int32_t index)
16682 {
16683 9565 ((enemy*)guys.spr(index))->scored=true;
16684 9565 }
16685
16686 2198 void addguy(int32_t x,int32_t y,int32_t id,int32_t clk,bool mainguy,mapscr* parentscr)
16687 {
16688
5/8
✓ Branch 0 taken 2198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2198 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 286 times.
✓ Branch 5 taken 1912 times.
✓ Branch 6 taken 2198 times.
✗ Branch 7 not taken.
2198 guy *g = new guy((zfix)x,(zfix)y,id,get_qr(qr_NOGUYPOOF)?0:clk,mainguy);
16689
2/2
✓ Branch 0 taken 1433 times.
✓ Branch 1 taken 765 times.
2198 if (isdungeon(g->screen_spawned))
16690 765 g->y += 1;
16691
5/6
✓ Branch 0 taken 1284 times.
✓ Branch 1 taken 914 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1280 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
2198 if(parentscr && parentscr->guytile > -1 && !get_qr(qr_OLD_GUY_HANDLING))
16692 {
16693 4 g->o_tile = parentscr->guytile;
16694
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(g->o_tile != 0)
16695 4 g->flags &= ~guy_invisible;
16696 4 g->cs = parentscr->guycs;
16697 4 }
16698 2198 guys.add(g);
16699 2198 }
16700
16701 23828 void additem(int32_t x,int32_t y,int32_t id,int32_t pickup)
16702 {
16703
4/8
✓ Branch 0 taken 23828 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23828 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23828 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 23828 times.
✗ Branch 7 not taken.
23828 item *i = new item(zfix(x), zfix(y - get_qr(qr_NOITEMOFFSET)), 0_zf, id, pickup, 0);
16704 23828 items.add(i);
16705 23828 }
16706
16707 150 void additem(int32_t x,int32_t y,int32_t id,int32_t pickup,int32_t clk)
16708 {
16709
5/10
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 150 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 150 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 150 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 150 times.
✗ Branch 9 not taken.
150 item *i = new item((zfix)x,(zfix)y-(get_qr(qr_NOITEMOFFSET)),(zfix)0,id,pickup,clk);
16710 150 items.add(i);
16711 150 }
16712
16713 3 void adddummyitem(int32_t x,int32_t y,int32_t id,int32_t pickup)
16714 {
16715
5/10
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3 times.
✗ Branch 9 not taken.
3 item *i = new item((zfix)x,(zfix)y-(get_qr(qr_NOITEMOFFSET)),(zfix)0,id,pickup,0,true);
16716 3 items.add(i);
16717 3 }
16718
16719 20075 void add_item_for_screen(int32_t screen, item* item)
16720 {
16721 20075 item->screen_spawned = screen;
16722 20075 items.add(item);
16723 20075 }
16724
16725 103 void kill_em_all()
16726 {
16727
2/2
✓ Branch 0 taken 361 times.
✓ Branch 1 taken 103 times.
464 for(int32_t i=0; i<guys.Count(); i++)
16728 {
16729 361 enemy *e = ((enemy*)guys.spr(i));
16730
16731
3/6
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 331 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 30 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
361 if(e->flags&(1<<3) && !(e->type == eeGHINI && e->dmisc1 == 1)) continue;
16732
16733 331 e->kickbucket();
16734 331 }
16735 103 }
16736
16737 bool can_kill_em_all()
16738 {
16739 for(int32_t i=0; i<guys.Count(); i++)
16740 {
16741 enemy *e = ((enemy*)guys.spr(i));
16742
16743 if(e->flags&(1<<3) && !(e->type == eeGHINI && e->dmisc1 == 1)) continue;
16744 if(e->superman) continue;
16745 return true;
16746 }
16747 return false;
16748 }
16749
16750 //This needs a quest rule, or enemy flag, Dying Enemy Doesn't Hurt Hero
16751 // For Hero's hit detection. Don't count them if they are stunned or are guys.
16752 int32_t GuyHit(int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
16753 {
16754 for(int32_t i=0; i<guys.Count(); i++)
16755 {
16756 if(guys.spr(i)->hit(tx,ty,tz,txsz,tysz,tzsz))
16757 {
16758 if(((enemy*)guys.spr(i))->stunclk==0 && ((enemy*)guys.spr(i))->frozenclock==0 && (!get_qr(qr_SAFEENEMYFADE) || ((enemy*)guys.spr(i))->fading != fade_flicker)
16759 &&(((enemy*)guys.spr(i))->d->type != eeGUY || ((enemy*)guys.spr(i))->dmisc1))
16760 {
16761 return i;
16762 }
16763 }
16764 }
16765
16766 return -1;
16767 }
16768
16769 13655609 int32_t GuyHitFrom(int32_t index,int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
16770 {
16771
4/4
✓ Branch 0 taken 16611 times.
✓ Branch 1 taken 13638998 times.
✓ Branch 2 taken 34780570 times.
✓ Branch 3 taken 13624161 times.
48404731 for(int32_t i=zc_max(0, index); i<guys.Count(); i++)
16772 {
16773
2/2
✓ Branch 0 taken 31448 times.
✓ Branch 1 taken 34749122 times.
34780570 if(guys.spr(i)->hit(tx,ty,tz,txsz,tysz,tzsz))
16774 {
16775 31448 return i;
16776 }
16777 34749122 }
16778
16779 13624161 return -1;
16780 13655609 }
16781
16782 // For Hero's hit detection. Count them if they are dying.
16783 54760 int32_t GuyHit(int32_t index,int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
16784 {
16785 54760 enemy *e = (enemy*)guys.spr(index);
16786
3/4
✓ Branch 0 taken 54760 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29580 times.
✓ Branch 3 taken 25180 times.
54760 if(!e || e->hp > 0)
16787 29580 return -1;
16788
16789 25180 bool d = e->dying;
16790 25180 int32_t hc = e->hclk;
16791 25180 e->dying = false;
16792 25180 e->hclk = 0;
16793 25180 bool hit = e->hit(tx,ty,tz,txsz,tysz,tzsz);
16794 25180 e->dying = d;
16795 25180 e->hclk = hc;
16796
16797
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 25023 times.
25180 return hit ? index : -1;
16798 54760 }
16799
16800 15201261 bool hasMainGuy(int screen)
16801 {
16802
2/2
✓ Branch 0 taken 16384185 times.
✓ Branch 1 taken 6127262 times.
22511447 for(int32_t i=0; i<guys.Count(); i++)
16803 {
16804 16384185 enemy* e = (enemy*)guys.spr(i);
16805
4/4
✓ Branch 0 taken 15921101 times.
✓ Branch 1 taken 463084 times.
✓ Branch 2 taken 9073999 times.
✓ Branch 3 taken 6847102 times.
16384185 if (e->screen_spawned == screen && e->mainguy)
16806 {
16807 9073999 return true;
16808 }
16809 7310186 }
16810
16811 6127262 return false;
16812 15201261 }
16813
16814 143 void EatHero(int32_t index)
16815 {
16816 143 ((eStalfos*)guys.spr(index))->eathero();
16817 143 }
16818
16819 9 void GrabHero(int32_t index)
16820 {
16821 9 ((eWallM*)guys.spr(index))->grabhero();
16822 9 }
16823
16824 1338 bool CarryHero()
16825 {
16826
1/2
✓ Branch 0 taken 3933 times.
✗ Branch 1 not taken.
3933 for(int32_t i=0; i<guys.Count(); i++)
16827 {
16828
2/2
✓ Branch 0 taken 2090 times.
✓ Branch 1 taken 1843 times.
3933 if(((guy*)(guys.spr(i)))->type==eeWALLM)
16829 {
16830
2/2
✓ Branch 0 taken 1338 times.
✓ Branch 1 taken 505 times.
1843 if(((eWallM*)guys.spr(i))->hashero)
16831 {
16832 1338 Hero.x=guys.spr(i)->x;
16833 1338 Hero.y=guys.spr(i)->y;
16834 1338 return ((eWallM*)guys.spr(i))->misc > 0;
16835 }
16836 505 }
16837
16838 // Like Likes currently can't carry Hero.
16839 /*
16840 if(((guy*)(guys.spr(i)))->family==eeLIKE)
16841 {
16842 if(((eLikeLike*)guys.spr(i))->hashero)
16843 {
16844 Hero.x=guys.spr(i)->x;
16845 Hero.y=guys.spr(i)->y;
16846 return (true);
16847 }
16848 }*/
16849 2595 }
16850
16851 return false;
16852 1338 }
16853
16854 // Move item with guy
16855 void movefairy(zfix &x,zfix &y,int32_t misc)
16856 {
16857 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
16858
16859 if(i!=-1)
16860 {
16861 x = guys.spr(i)->x;
16862 y = guys.spr(i)->y;
16863 }
16864 }
16865
16866 // Move guy with item (used by FFC scripts and hookshot-dragged fairies)
16867 void movefairy2(zfix x,zfix y,int32_t misc)
16868 {
16869 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
16870
16871 if(i!=-1)
16872 {
16873 guys.spr(i)->x = x;
16874 guys.spr(i)->y = y;
16875 }
16876 }// Move item with guy
16877
16878 61175 void movefairynew(zfix &x,zfix &y, item const &itemfairy)
16879 {
16880 61175 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
16881
16882
1/2
✓ Branch 0 taken 61175 times.
✗ Branch 1 not taken.
61175 if(fairy)
16883 {
16884 61175 x = fairy->x;
16885 61175 y = fairy->y;
16886 61175 }
16887 61175 }
16888
16889 // Move guy with item (used by FFC scripts and hookshot-dragged fairies)
16890 404 void movefairynew2(zfix x,zfix y, item const &itemfairy)
16891 {
16892 404 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
16893
16894
1/2
✓ Branch 0 taken 404 times.
✗ Branch 1 not taken.
404 if(fairy)
16895 {
16896 404 fairy->x = x;
16897 404 fairy->y = y;
16898 404 }
16899 404 }
16900
16901 void killfairy(int32_t misc)
16902 {
16903 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
16904 guys.del(i);
16905 }
16906
16907 223 int32_t getGuyIndex(const int32_t eid)
16908 {
16909
1/2
✓ Branch 0 taken 846 times.
✗ Branch 1 not taken.
846 for(word i = 0; i < guys.Count(); i++)
16910 {
16911
2/2
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 623 times.
846 if(guys.spr(i)->getUID() == eid)
16912 223 return i;
16913 623 }
16914
16915 return -1;
16916 223 }
16917
16918 223 void killfairynew(item const &itemfairy)
16919 {
16920 223 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
16921
1/2
✓ Branch 0 taken 223 times.
✗ Branch 1 not taken.
223 if (fairy != NULL) guys.del(getGuyIndex(itemfairy.fairyUID));
16922 223 }
16923
16924 //Should probably change this to return an 'enemy*', null on failure -Em
16925 22075 int32_t addenemy(int32_t screen, int32_t x,int32_t y,int32_t id,int32_t clk)
16926 {
16927 22075 return addenemy_z(screen,x,y,0,id,clk);
16928 }
16929
16930 1965 int32_t addchild(int32_t screen, int32_t x,int32_t y,int32_t id,int32_t clk, sprite* parent)
16931 {
16932 1965 return addchild_z(screen,x,y,0,id,clk, parent);
16933 }
16934
16935 1997 int32_t addchild_z(int32_t screen, int32_t x,int32_t y,int32_t z,int32_t id,int32_t clk, sprite* parent)
16936 {
16937
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1997 times.
1997 if(id <= 0) return 0;
16938
16939 1997 int32_t ret = 0;
16940 1997 sprite *e=NULL;
16941
16942
6/31
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 110 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1865 times.
✓ Branch 10 taken 15 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 1 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 2 times.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 4 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
1997 switch(guysbuf[id&0xFFF].type)
16943 {
16944 //Fixme: possible enemy memory leak. (minor)
16945 case eeWALK:
16946
3/6
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 110 times.
✗ Branch 5 not taken.
110 e = new eStalfos((zfix)x,(zfix)y,id,clk);
16947 110 break;
16948
16949 case eeLEV:
16950 e = new eLeever((zfix)x,(zfix)y,id,clk);
16951 break;
16952
16953 case eeTEK:
16954 e = new eTektite((zfix)x,(zfix)y,id,clk);
16955 break;
16956
16957 case eePEAHAT:
16958 e = new ePeahat((zfix)x,(zfix)y,id,clk);
16959 break;
16960
16961 case eeZORA:
16962 e = new eZora((zfix)x,(zfix)y,id,clk);
16963 break;
16964
16965 case eeGHINI:
16966 e = new eGhini((zfix)x,(zfix)y,id,clk);
16967 break;
16968
16969 case eeKEESE:
16970
3/6
✓ Branch 0 taken 1865 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1865 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1865 times.
✗ Branch 5 not taken.
1865 e = new eKeese((zfix)x,(zfix)y,id,clk);
16971 1865 break;
16972
16973 case eeWIZZ:
16974
3/6
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
15 e = new eWizzrobe((zfix)x,(zfix)y,id,clk);
16975 15 break;
16976
16977 case eePROJECTILE:
16978 e = new eProjectile((zfix)x,(zfix)y,id,clk);
16979 break;
16980
16981 case eeWALLM:
16982 e = new eWallM((zfix)x,(zfix)y,id,clk);
16983 break;
16984
16985 case eeAQUA:
16986 e = new eAquamentus((zfix)x,(zfix)y,id,clk);
16987 break;
16988
16989 case eeMOLD:
16990 e = new eMoldorm((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
16991 break;
16992
16993 case eeMANHAN:
16994
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 e = new eManhandla((zfix)x,(zfix)y,id,clk);
16995 1 break;
16996
16997 case eeGLEEOK:
16998 e = new eGleeok((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
16999 break;
17000
17001 case eeGHOMA:
17002 e = new eGohma((zfix)x,(zfix)y,id,clk);
17003 break;
17004
17005 case eeLANM:
17006 e = new eLanmola((zfix)x,(zfix)y,id,zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])));
17007 break;
17008
17009 case eeGANON:
17010 e = new eGanon((zfix)x,(zfix)y,id,clk);
17011 break;
17012
17013 case eeFAIRY:
17014 e = new eItemFairy((zfix)x,(zfix)y,id+0x1000*clk,clk);
17015 break;
17016
17017 case eeFIRE:
17018
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
2 e = new eFire((zfix)x,(zfix)y,id,clk);
17019 2 break;
17020
17021 case eeOTHER:
17022 e = new eOther((zfix)x,(zfix)y,id,clk);
17023 break;
17024
17025
17026 case eeSCRIPT01:
17027 case eeSCRIPT02:
17028 case eeSCRIPT03:
17029 case eeSCRIPT04:
17030 case eeSCRIPT05:
17031 case eeSCRIPT06:
17032 case eeSCRIPT07:
17033 case eeSCRIPT08:
17034 case eeSCRIPT09:
17035 case eeSCRIPT10:
17036 case eeSCRIPT11:
17037 case eeSCRIPT12:
17038 case eeSCRIPT13:
17039 case eeSCRIPT14:
17040 case eeSCRIPT15:
17041 case eeSCRIPT16:
17042 case eeSCRIPT17:
17043 case eeSCRIPT18:
17044 case eeSCRIPT19:
17045 case eeSCRIPT20:
17046 {
17047 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17048 {
17049 e = new eScript((zfix)x,(zfix)y,id,clk);
17050 break;
17051 }
17052 else return 0;
17053 }
17054
17055 case eeFFRIENDLY01:
17056 case eeFFRIENDLY02:
17057 case eeFFRIENDLY03:
17058 case eeFFRIENDLY04:
17059 case eeFFRIENDLY05:
17060 case eeFFRIENDLY06:
17061 case eeFFRIENDLY07:
17062 case eeFFRIENDLY08:
17063 case eeFFRIENDLY09:
17064 case eeFFRIENDLY10:
17065 {
17066 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17067 {
17068 e = new eFriendly((zfix)x,(zfix)y,id,clk); break;
17069 }
17070 else return 0;
17071
17072 }
17073
17074 case eeSPINTILE:
17075 e = new eSpinTile((zfix)x,(zfix)y,id,clk);
17076 break;
17077
17078 // and these enemies use the misc10/misc2 value
17079 case eeROCK:
17080 {
17081 switch(guysbuf[id&0xFFF].attributes[9])
17082 {
17083 case 1:
17084 e = new eBoulder((zfix)x,(zfix)y,id,clk);
17085 break;
17086
17087 case 0:
17088 default:
17089 e = new eRock((zfix)x,(zfix)y,id,clk);
17090 break;
17091 }
17092
17093 break;
17094 }
17095
17096 case eeTRAP:
17097 {
17098 switch(guysbuf[id&0xFFF].attributes[1])
17099 {
17100 case 1:
17101 e = new eTrap2((zfix)x,(zfix)y,id,clk);
17102 break;
17103
17104 case 0:
17105 default:
17106 e = new eTrap((zfix)x,(zfix)y,id,clk);
17107 break;
17108 }
17109
17110 break;
17111 }
17112
17113 case eeDONGO:
17114 {
17115 switch(guysbuf[id&0xFFF].attributes[9])
17116 {
17117 case 1:
17118 e = new eDodongo2((zfix)x,(zfix)y,id,clk);
17119 break;
17120
17121 case 0:
17122 default:
17123 e = new eDodongo((zfix)x,(zfix)y,id,clk);
17124 break;
17125 }
17126
17127 break;
17128 }
17129
17130 case eeDIG:
17131 {
17132
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 switch(guysbuf[id&0xFFF].attributes[9])
17133 {
17134 case 1:
17135 e = new eLilDig((zfix)x,(zfix)y,id,clk);
17136 break;
17137
17138 4 case 0:
17139 default:
17140
3/6
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
4 e = new eBigDig((zfix)x,(zfix)y,id,clk);
17141 4 break;
17142 }
17143
17144 4 break;
17145 }
17146
17147 case eePATRA:
17148 {
17149 switch(guysbuf[id&0xFFF].attributes[9])
17150 {
17151 case 1:
17152 if (get_qr(qr_HARDCODED_BS_PATRA))
17153 {
17154 e = new ePatraBS((zfix)x,(zfix)y,id,clk);
17155 break;
17156 }
17157 [[fallthrough]];
17158 case 0:
17159 default:
17160 e = new ePatra((zfix)x,(zfix)y,id,clk);
17161 break;
17162 }
17163
17164 break;
17165 }
17166
17167 case eeGUY:
17168 {
17169 switch(guysbuf[id&0xFFF].attributes[9])
17170 {
17171 case 1:
17172 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17173 break;
17174
17175 case 0:
17176 default:
17177 e = new eNPC((zfix)x,(zfix)y,id,clk);
17178 break;
17179 }
17180
17181 break;
17182 }
17183
17184 case eeNONE:
17185 if(guysbuf[id&0xFFF].attributes[9] ==1)
17186 {
17187 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17188 break;
17189 break;
17190 }
17191 [[fallthrough]];
17192 default:
17193
17194 return 0;
17195 }
17196
17197 1997 ret++; // Made one enemy.
17198
17199
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1990 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
1997 if(z && canfall(id))
17200 {
17201 7 e->z = (zfix)z;
17202 7 }
17203
17204
2/2
✓ Branch 0 taken 1990 times.
✓ Branch 1 taken 7 times.
1997 ((enemy*)e)->ceiling = (z && canfall(id));
17205 1997 e->setParent(parent);
17206
17207
1/2
✓ Branch 0 taken 1997 times.
✗ Branch 1 not taken.
1997 if(!guys.add(e))
17208 {
17209 return 0;
17210 }
17211
17212 // add segments of segmented enemies
17213 1997 int32_t c=0;
17214
17215
2/6
✓ Branch 0 taken 1996 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1997 switch(guysbuf[id&0xFFF].type)
17216 {
17217 case eeMOLD:
17218 {
17219 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
17220 id &= 0xFFF;
17221
17222 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id].attributes[0])); i++)
17223 {
17224 //christ this is messy -DD
17225 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[id&0xFFF].step*100))));
17226
17227 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,id+0x1000,segclk)))
17228 {
17229 al_trace("Moldorm segment %d could not be created!\n",i+1);
17230
17231 for(int32_t j=0; j<i+1; j++)
17232 guys.del(guys.Count()-1);
17233
17234 return 0;
17235 }
17236
17237 if(i>0)
17238 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
17239
17240 ret++;
17241 }
17242
17243 break;
17244 }
17245
17246 case eeLANM:
17247 {
17248 id &= 0xFFF;
17249 int32_t shft = guysbuf[id].attributes[1];
17250 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
17251
17252 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x1000,0)))
17253 {
17254 al_trace("Lanmola segment 1 could not be created!\n");
17255 guys.del(guys.Count()-1);
17256 return 0;
17257 }
17258
17259 ret++;
17260
17261 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])); i++)
17262 {
17263 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x2000,-(i<<shft))))
17264 {
17265 al_trace("Lanmola segment %d could not be created!\n",i+1);
17266
17267 for(int32_t j=0; j<i+1; j++)
17268 guys.del(guys.Count()-1);
17269
17270 return 0;
17271 }
17272
17273 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
17274 ret++;
17275 }
17276 }
17277 break;
17278
17279 case eeMANHAN:
17280 1 id &= 0xFFF;
17281
17282
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t i=0; i<((!(guysbuf[id].attributes[1]))?4:8); i++)
17283 {
17284
4/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
4 if(!guys.add(new esManhandla((zfix)x,(zfix)y,id+0x1000,i)))
17285 {
17286 al_trace("Manhandla head %d could not be created!\n",i+1);
17287
17288 for(int32_t j=0; j<i+1; j++)
17289 {
17290 guys.del(guys.Count()-1);
17291 }
17292
17293 return 0;
17294 }
17295
17296 4 ret++;
17297 4 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[id].attributes[0];
17298 4 }
17299
17300 1 break;
17301
17302 case eeGLEEOK:
17303 {
17304 id &= 0xFFF;
17305
17306 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])); i++)
17307 {
17308 if(!guys.add(new esGleeok((zfix)x,(zfix)y,id+0x1000,c, e)))
17309 {
17310 al_trace("Gleeok head %d could not be created!\n",i+1);
17311
17312 for(int32_t j=0; j<i+1; j++)
17313 {
17314 guys.del(guys.Count()-1);
17315 }
17316
17317 return false;
17318 }
17319
17320 c-=guysbuf[id].attributes[3];
17321 ret++;
17322 }
17323 }
17324 break;
17325
17326
17327 case eePATRA:
17328 {
17329 id &= 0xFFF;
17330 int32_t outeyes = 0;
17331
17332 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[0]); i++)
17333 {
17334 if(!((guysbuf[id].attributes[9] &&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,id+0x1000,i,e)):guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e))))
17335 {
17336 al_trace("Patra outer eye %d could not be created!\n",i+1);
17337
17338 for(int32_t j=0; j<i+1; j++)
17339 guys.del(guys.Count()-1);
17340
17341 return 0;
17342 }
17343 else
17344 outeyes++;
17345
17346 ret++;
17347 }
17348
17349 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[1]); i++)
17350 {
17351 if(!guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e)))
17352 {
17353 al_trace("Patra inner eye %d could not be created!\n",i+1);
17354
17355 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
17356 guys.del(guys.Count()-1);
17357
17358 return 0;
17359 }
17360
17361 ret++;
17362 }
17363
17364 break;
17365 }
17366 }
17367
17368
2/2
✓ Branch 0 taken 2001 times.
✓ Branch 1 taken 1997 times.
3998 for (int i = 0; i < ret; i++)
17369 {
17370 2001 enemy* e = (enemy*)guys.spr(guys.Count() - 1 - i);
17371 2001 e->screen_spawned = screen;
17372 2001 }
17373
17374 1997 return ret;
17375 1997 }
17376
17377 // Returns number of enemies/segments created
17378 106085 int32_t addenemy_z(int32_t screen,int32_t x,int32_t y,int32_t z,int32_t id,int32_t clk)
17379 {
17380 106085 int32_t realid = id&0xFFF;
17381
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106085 times.
106085 if( realid > MAXGUYS )
17382 {
17383 return 0;
17384 }
17385
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106085 times.
106085 if(id <= 0) return 0;
17386
17387 106085 int32_t ret = 0;
17388 106085 sprite *e=NULL;
17389
17390
29/31
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 52443 times.
✓ Branch 4 taken 4434 times.
✓ Branch 5 taken 5303 times.
✓ Branch 6 taken 1833 times.
✓ Branch 7 taken 2874 times.
✓ Branch 8 taken 461 times.
✓ Branch 9 taken 12539 times.
✓ Branch 10 taken 5335 times.
✓ Branch 11 taken 4433 times.
✓ Branch 12 taken 998 times.
✓ Branch 13 taken 126 times.
✓ Branch 14 taken 618 times.
✓ Branch 15 taken 149 times.
✓ Branch 16 taken 168 times.
✓ Branch 17 taken 93 times.
✓ Branch 18 taken 420 times.
✓ Branch 19 taken 13 times.
✓ Branch 20 taken 736 times.
✓ Branch 21 taken 758 times.
✓ Branch 22 taken 7780 times.
✓ Branch 23 taken 94 times.
✓ Branch 24 taken 384 times.
✓ Branch 25 taken 2573 times.
✓ Branch 26 taken 257 times.
✓ Branch 27 taken 403 times.
✓ Branch 28 taken 292 times.
✓ Branch 29 taken 5 times.
✓ Branch 30 taken 533 times.
106085 switch(guysbuf[id&0xFFF].type)
17391 {
17392 //Fixme: possible enemy memory leak. (minor)
17393 case eeWALK:
17394
3/6
✓ Branch 0 taken 52443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 52443 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 52443 times.
✗ Branch 5 not taken.
52443 e = new eStalfos((zfix)x,(zfix)y,id,clk);
17395 52443 break;
17396
17397 case eeLEV:
17398
3/6
✓ Branch 0 taken 4434 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4434 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4434 times.
✗ Branch 5 not taken.
4434 e = new eLeever((zfix)x,(zfix)y,id,clk);
17399 4434 break;
17400
17401 case eeTEK:
17402
3/6
✓ Branch 0 taken 5303 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5303 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5303 times.
✗ Branch 5 not taken.
5303 e = new eTektite((zfix)x,(zfix)y,id,clk);
17403 5303 break;
17404
17405 case eePEAHAT:
17406
3/6
✓ Branch 0 taken 1833 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1833 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1833 times.
✗ Branch 5 not taken.
1833 e = new ePeahat((zfix)x,(zfix)y,id,clk);
17407 1833 break;
17408
17409 case eeZORA:
17410
3/6
✓ Branch 0 taken 2874 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2874 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2874 times.
✗ Branch 5 not taken.
2874 e = new eZora((zfix)x,(zfix)y,id,clk);
17411 2874 break;
17412
17413 case eeGHINI:
17414
3/6
✓ Branch 0 taken 461 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 461 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 461 times.
✗ Branch 5 not taken.
461 e = new eGhini((zfix)x,(zfix)y,id,clk);
17415 461 break;
17416
17417 case eeKEESE:
17418
3/6
✓ Branch 0 taken 12539 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12539 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12539 times.
✗ Branch 5 not taken.
12539 e = new eKeese((zfix)x,(zfix)y,id,clk);
17419 12539 break;
17420
17421 case eeWIZZ:
17422
3/6
✓ Branch 0 taken 5335 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5335 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5335 times.
✗ Branch 5 not taken.
5335 e = new eWizzrobe((zfix)x,(zfix)y,id,clk);
17423 5335 break;
17424
17425 case eePROJECTILE:
17426
3/6
✓ Branch 0 taken 4433 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4433 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4433 times.
✗ Branch 5 not taken.
4433 e = new eProjectile((zfix)x,(zfix)y,id,clk);
17427 4433 break;
17428
17429 case eeWALLM:
17430
3/6
✓ Branch 0 taken 998 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 998 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 998 times.
✗ Branch 5 not taken.
998 e = new eWallM((zfix)x,(zfix)y,id,clk);
17431 998 break;
17432
17433 case eeAQUA:
17434
3/6
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 126 times.
✗ Branch 5 not taken.
126 e = new eAquamentus((zfix)x,(zfix)y,id,clk);
17435 126 break;
17436
17437 case eeMOLD:
17438
6/12
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 618 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 618 times.
✓ Branch 6 taken 618 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 618 times.
✓ Branch 10 taken 618 times.
✗ Branch 11 not taken.
618 e = new eMoldorm((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
17439 618 break;
17440
17441 case eeMANHAN:
17442
3/6
✓ Branch 0 taken 149 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 149 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 149 times.
✗ Branch 5 not taken.
149 e = new eManhandla((zfix)x,(zfix)y,id,clk);
17443 149 break;
17444
17445 case eeGLEEOK:
17446
7/12
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 168 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 168 times.
✓ Branch 6 taken 152 times.
✓ Branch 7 taken 16 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 152 times.
✓ Branch 10 taken 168 times.
✗ Branch 11 not taken.
168 e = new eGleeok((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
17447 168 break;
17448
17449 case eeGHOMA:
17450
3/6
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 93 times.
✗ Branch 5 not taken.
93 e = new eGohma((zfix)x,(zfix)y,id,clk);
17451 93 break;
17452
17453 case eeLANM:
17454
6/12
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 420 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 420 times.
✓ Branch 6 taken 420 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 420 times.
✓ Branch 10 taken 420 times.
✗ Branch 11 not taken.
420 e = new eLanmola((zfix)x,(zfix)y,id,zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])));
17455 420 break;
17456
17457 case eeGANON:
17458
3/6
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
13 e = new eGanon((zfix)x,(zfix)y,id,clk);
17459 13 break;
17460
17461 case eeFAIRY:
17462
3/6
✓ Branch 0 taken 736 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 736 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 736 times.
✗ Branch 5 not taken.
736 e = new eItemFairy((zfix)x,(zfix)y,id+0x1000*clk,clk);
17463 736 break;
17464
17465 case eeFIRE:
17466
3/6
✓ Branch 0 taken 758 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 758 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 758 times.
✗ Branch 5 not taken.
758 e = new eFire((zfix)x,(zfix)y,id,clk);
17467 758 break;
17468
17469 case eeOTHER:
17470
3/6
✓ Branch 0 taken 7780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7780 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7780 times.
✗ Branch 5 not taken.
7780 e = new eOther((zfix)x,(zfix)y,id,clk);
17471 7780 break;
17472
17473
17474 case eeSCRIPT01:
17475 case eeSCRIPT02:
17476 case eeSCRIPT03:
17477 case eeSCRIPT04:
17478 case eeSCRIPT05:
17479 case eeSCRIPT06:
17480 case eeSCRIPT07:
17481 case eeSCRIPT08:
17482 case eeSCRIPT09:
17483 case eeSCRIPT10:
17484 case eeSCRIPT11:
17485 case eeSCRIPT12:
17486 case eeSCRIPT13:
17487 case eeSCRIPT14:
17488 case eeSCRIPT15:
17489 case eeSCRIPT16:
17490 case eeSCRIPT17:
17491 case eeSCRIPT18:
17492 case eeSCRIPT19:
17493 case eeSCRIPT20:
17494 {
17495
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17496 {
17497
3/6
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 30 times.
✗ Branch 5 not taken.
30 e = new eScript((zfix)x,(zfix)y,id,clk);
17498 30 break;
17499 }
17500 else return 0;
17501 }
17502
17503 case eeFFRIENDLY01:
17504 case eeFFRIENDLY02:
17505 case eeFFRIENDLY03:
17506 case eeFFRIENDLY04:
17507 case eeFFRIENDLY05:
17508 case eeFFRIENDLY06:
17509 case eeFFRIENDLY07:
17510 case eeFFRIENDLY08:
17511 case eeFFRIENDLY09:
17512 case eeFFRIENDLY10:
17513 {
17514 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17515 {
17516 e = new eFriendly((zfix)x,(zfix)y,id,clk); break;
17517 }
17518 else return 0;
17519
17520 }
17521
17522 case eeSPINTILE:
17523
3/6
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 94 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 94 times.
✗ Branch 5 not taken.
94 e = new eSpinTile((zfix)x,(zfix)y,id,clk);
17524 94 break;
17525
17526 // and these enemies use the misc10/misc2 value
17527 case eeROCK:
17528 {
17529
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 354 times.
384 switch(guysbuf[id&0xFFF].attributes[9])
17530 {
17531 case 1:
17532
3/6
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 30 times.
✗ Branch 5 not taken.
30 e = new eBoulder((zfix)x,(zfix)y,id,clk);
17533 30 break;
17534
17535 354 case 0:
17536 default:
17537
3/6
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 354 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 354 times.
✗ Branch 5 not taken.
354 e = new eRock((zfix)x,(zfix)y,id,clk);
17538 354 break;
17539 }
17540
17541 384 break;
17542 }
17543
17544 case eeTRAP:
17545 {
17546
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 893 times.
✓ Branch 2 taken 1680 times.
2573 switch(guysbuf[id&0xFFF].attributes[1])
17547 {
17548 case 1:
17549
3/6
✓ Branch 0 taken 893 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 893 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 893 times.
✗ Branch 5 not taken.
893 e = new eTrap2((zfix)x,(zfix)y,id,clk);
17550 893 break;
17551
17552 1680 case 0:
17553 default:
17554
3/6
✓ Branch 0 taken 1680 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1680 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1680 times.
✗ Branch 5 not taken.
1680 e = new eTrap((zfix)x,(zfix)y,id,clk);
17555 1680 break;
17556 }
17557
17558 2573 break;
17559 }
17560
17561 case eeDONGO:
17562 {
17563
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 209 times.
257 switch(guysbuf[id&0xFFF].attributes[9])
17564 {
17565 case 1:
17566
3/6
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
48 e = new eDodongo2((zfix)x,(zfix)y,id,clk);
17567 48 break;
17568
17569 209 case 0:
17570 default:
17571
3/6
✓ Branch 0 taken 209 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 209 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 209 times.
✗ Branch 5 not taken.
209 e = new eDodongo((zfix)x,(zfix)y,id,clk);
17572 209 break;
17573 }
17574
17575 257 break;
17576 }
17577
17578 case eeDIG:
17579 {
17580
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 327 times.
✓ Branch 2 taken 76 times.
403 switch(guysbuf[id&0xFFF].attributes[9])
17581 {
17582 case 1:
17583
3/6
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 327 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 327 times.
✗ Branch 5 not taken.
327 e = new eLilDig((zfix)x,(zfix)y,id,clk);
17584 327 break;
17585
17586 76 case 0:
17587 default:
17588
3/6
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 76 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 76 times.
✗ Branch 5 not taken.
76 e = new eBigDig((zfix)x,(zfix)y,id,clk);
17589 76 break;
17590 }
17591
17592 403 break;
17593 }
17594
17595 case eePATRA:
17596 {
17597
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✓ Branch 2 taken 102 times.
292 switch(guysbuf[id&0xFFF].attributes[9])
17598 {
17599 case 1:
17600
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if (get_qr(qr_HARDCODED_BS_PATRA))
17601 {
17602
3/6
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 102 times.
✗ Branch 5 not taken.
102 e = new ePatraBS((zfix)x,(zfix)y,id,clk);
17603 102 break;
17604 }
17605 [[fallthrough]];
17606 190 case 0:
17607 default:
17608
3/6
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 190 times.
✗ Branch 5 not taken.
190 e = new ePatra((zfix)x,(zfix)y,id,clk);
17609 190 break;
17610 }
17611
17612 292 break;
17613 }
17614
17615 case eeGUY:
17616 {
17617
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
5 switch(guysbuf[id&0xFFF].attributes[9])
17618 {
17619 case 1:
17620 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17621 break;
17622
17623 5 case 0:
17624 default:
17625
3/6
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
5 e = new eNPC((zfix)x,(zfix)y,id,clk);
17626 5 break;
17627 }
17628
17629 5 break;
17630 }
17631
17632 case eeNONE:
17633
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 if(guysbuf[id&0xFFF].attributes[9] ==1)
17634 {
17635
3/6
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
533 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17636 533 break;
17637 }
17638 [[fallthrough]];
17639 default:
17640
17641 return 0;
17642 }
17643
17644 106085 ret++; // Made one enemy.
17645
17646
4/4
✓ Branch 0 taken 278 times.
✓ Branch 1 taken 105807 times.
✓ Branch 2 taken 46 times.
✓ Branch 3 taken 232 times.
106085 if(z && canfall(id))
17647 {
17648 232 e->z = (zfix)z;
17649 232 }
17650
17651
2/2
✓ Branch 0 taken 105807 times.
✓ Branch 1 taken 278 times.
106085 ((enemy*)e)->ceiling = (z && canfall(id));
17652
17653
1/2
✓ Branch 0 taken 106085 times.
✗ Branch 1 not taken.
106085 if(!guys.add(e))
17654 {
17655 return 0;
17656 }
17657
17658 // add segments of segmented enemies
17659 106085 int32_t c=0;
17660
17661
6/6
✓ Branch 0 taken 104438 times.
✓ Branch 1 taken 618 times.
✓ Branch 2 taken 420 times.
✓ Branch 3 taken 149 times.
✓ Branch 4 taken 168 times.
✓ Branch 5 taken 292 times.
106085 switch(guysbuf[id&0xFFF].type)
17662 {
17663 case eeMOLD:
17664 {
17665 618 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
17666 618 id &= 0xFFF;
17667
17668
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 3768 times.
✓ Branch 2 taken 3768 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3768 times.
✓ Branch 6 taken 3150 times.
✓ Branch 7 taken 618 times.
3768 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id].attributes[0])); i++)
17669 {
17670 //christ this is messy -DD
17671 3150 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[id&0xFFF].step*100))));
17672
17673
4/8
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3150 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3150 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3150 times.
✗ Branch 7 not taken.
3150 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,id+0x1000,segclk)))
17674 {
17675 al_trace("Moldorm segment %d could not be created!\n",i+1);
17676
17677 for(int32_t j=0; j<i+1; j++)
17678 guys.del(guys.Count()-1);
17679
17680 return 0;
17681 }
17682
17683
2/2
✓ Branch 0 taken 618 times.
✓ Branch 1 taken 2532 times.
3150 if(i>0)
17684 2532 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
17685
17686 3150 ret++;
17687 3150 }
17688
17689 618 break;
17690 }
17691
17692 case eeLANM:
17693 {
17694 420 id &= 0xFFF;
17695 420 int32_t shft = guysbuf[id].attributes[1];
17696 420 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
17697
17698
4/8
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 420 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 420 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 420 times.
✗ Branch 7 not taken.
420 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x1000,0)))
17699 {
17700 al_trace("Lanmola segment 1 could not be created!\n");
17701 guys.del(guys.Count()-1);
17702 return 0;
17703 }
17704
17705 420 ret++;
17706
17707
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2267 times.
✓ Branch 2 taken 2267 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2267 times.
✓ Branch 6 taken 1847 times.
✓ Branch 7 taken 420 times.
2267 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])); i++)
17708 {
17709
4/8
✓ Branch 0 taken 1847 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1847 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1847 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1847 times.
✗ Branch 7 not taken.
1847 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x2000,-(i<<shft))))
17710 {
17711 al_trace("Lanmola segment %d could not be created!\n",i+1);
17712
17713 for(int32_t j=0; j<i+1; j++)
17714 guys.del(guys.Count()-1);
17715
17716 return 0;
17717 }
17718
17719 1847 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
17720 1847 ret++;
17721 1847 }
17722 }
17723 420 break;
17724
17725 case eeMANHAN:
17726 149 id &= 0xFFF;
17727
17728
2/2
✓ Branch 0 taken 688 times.
✓ Branch 1 taken 149 times.
837 for(int32_t i=0; i<((!(guysbuf[id].attributes[1]))?4:8); i++)
17729 {
17730
4/8
✓ Branch 0 taken 688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 688 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 688 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 688 times.
✗ Branch 7 not taken.
688 if(!guys.add(new esManhandla((zfix)x,(zfix)y,id+0x1000,i)))
17731 {
17732 al_trace("Manhandla head %d could not be created!\n",i+1);
17733
17734 for(int32_t j=0; j<i+1; j++)
17735 {
17736 guys.del(guys.Count()-1);
17737 }
17738
17739 return 0;
17740 }
17741
17742 688 ret++;
17743 688 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[id].attributes[0];
17744 688 }
17745
17746 149 break;
17747
17748 case eeGLEEOK:
17749 {
17750 168 id &= 0xFFF;
17751 168 eGleeok* parent = (eGleeok*)e;
17752
17753
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 701 times.
✓ Branch 2 taken 669 times.
✓ Branch 3 taken 32 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 669 times.
✓ Branch 6 taken 533 times.
✓ Branch 7 taken 168 times.
701 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])); i++)
17754 {
17755
3/6
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
533 esGleeok* head = new esGleeok((zfix)x,(zfix)y,id+0x1000,c, e);
17756
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 if(!guys.add(head))
17757 {
17758 al_trace("Gleeok head %d could not be created!\n",i+1);
17759
17760 for(int32_t j=0; j<i+1; j++)
17761 {
17762 guys.del(guys.Count()-1);
17763 }
17764
17765 return false;
17766 }
17767
17768 533 head->necktile=parent->necktile;
17769 533 head->dummy_int[1]=parent->necktile;
17770
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 112 times.
533 if(get_qr(qr_NEWENEMYTILES))
17771 {
17772 421 head->dummy_int[2]=parent->o_tile+parent->dmisc8; //connected head tile
17773 421 head->dummy_int[3]=parent->o_tile+parent->dmisc9; //flying head tile
17774 421 }
17775 else
17776 {
17777 112 head->dummy_int[2]=parent->necktile+1; //connected head tile
17778 112 head->dummy_int[3]=parent->necktile+2; //flying head tile
17779 }
17780 533 head->tile = head->dummy_int[2];
17781
17782 533 c-=guysbuf[id].attributes[3];
17783 533 ret++;
17784 533 }
17785 }
17786 168 break;
17787
17788
17789 case eePATRA:
17790 {
17791 292 id &= 0xFFF;
17792 292 int32_t outeyes = 0;
17793
17794
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2248 times.
✓ Branch 2 taken 1956 times.
✓ Branch 3 taken 292 times.
2248 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[0]); i++)
17795 {
17796
10/22
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 1344 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 612 times.
✓ Branch 4 taken 612 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 612 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 612 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1344 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1344 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1344 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 1344 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
1956 if(!((guysbuf[id].attributes[9] &&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,id+0x1000,i,e)):guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e))))
17797 {
17798 al_trace("Patra outer eye %d could not be created!\n",i+1);
17799
17800 for(int32_t j=0; j<i+1; j++)
17801 guys.del(guys.Count()-1);
17802
17803 return 0;
17804 }
17805 else
17806 1956 outeyes++;
17807
17808 1956 ret++;
17809 1956 }
17810
17811
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 604 times.
✓ Branch 2 taken 312 times.
✓ Branch 3 taken 292 times.
604 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[1]); i++)
17812 {
17813
4/8
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 312 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 312 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 312 times.
✗ Branch 7 not taken.
312 if(!guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e)))
17814 {
17815 al_trace("Patra inner eye %d could not be created!\n",i+1);
17816
17817 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
17818 guys.del(guys.Count()-1);
17819
17820 return 0;
17821 }
17822
17823 312 ret++;
17824 312 }
17825
17826 292 break;
17827 }
17828 }
17829
17830
2/2
✓ Branch 0 taken 114991 times.
✓ Branch 1 taken 106085 times.
221076 for (int i = 0; i < ret; i++)
17831 {
17832 114991 enemy* e = (enemy*)guys.spr(guys.Count() - 1 - i);
17833 114991 e->screen_spawned = screen;
17834 114991 }
17835
17836 106085 return ret;
17837 106085 }
17838
17839 2069977 bool isjumper(int32_t id)
17840 {
17841
2/4
✓ Branch 0 taken 2069977 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2069977 times.
2069977 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
17842 {
17843 return false;
17844 }
17845
3/3
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 1963949 times.
✓ Branch 2 taken 106019 times.
2069977 switch(guysbuf[id&0xFFF].type)
17846 {
17847 case eeROCK:
17848 case eeTEK:
17849 9 return true;
17850
17851 case eeWALK:
17852
3/4
✓ Branch 0 taken 106019 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12265 times.
✓ Branch 3 taken 93754 times.
106019 if(guysbuf[id&0xFFF].attributes[8] == e9tVIRE || guysbuf[id & 0xFFF].attributes[8] == e9tPOLSVOICE) return true;
17853 93754 }
17854
17855 2057703 return false;
17856 2069977 }
17857
17858
17859 8068 bool isfixedtogrid(int32_t id)
17860 {
17861
2/4
✓ Branch 0 taken 8068 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8068 times.
8068 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
17862 {
17863 return false;
17864 }
17865
1/2
✓ Branch 0 taken 8068 times.
✗ Branch 1 not taken.
8068 switch(guysbuf[id&0xFFF].type)
17866 {
17867 case eeWALK:
17868 case eeLEV:
17869 case eeZORA:
17870 case eeDONGO:
17871 case eeGANON:
17872 case eeROCK:
17873 case eeGLEEOK:
17874 case eeAQUA:
17875 case eeLANM:
17876 return true;
17877 }
17878
17879 8068 return false;
17880 8068 }
17881
17882 // Can't fall, can have Z value.
17883 78266434 bool isflier(int32_t id)
17884 {
17885
3/4
✓ Branch 0 taken 78266434 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110858 times.
✓ Branch 3 taken 78155576 times.
78266434 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
17886 {
17887 110858 return false;
17888 }
17889
2/2
✓ Branch 0 taken 14392561 times.
✓ Branch 1 taken 63763015 times.
78155576 switch(guysbuf[id&0xFFF].type) //id&0x0FFF)
17890 {
17891 case eePEAHAT:
17892 case eeKEESE:
17893 case eePATRA:
17894 case eeFAIRY:
17895 case eeGHINI:
17896
17897 // Could theoretically have their Z set by a script
17898 case eeFIRE:
17899 14392561 return true;
17900 break;
17901 }
17902
17903 63763015 return false;
17904 78266434 }
17905
17906 // Can't have Z position
17907 4056840 bool never_in_air(int32_t id)
17908 {
17909
2/4
✓ Branch 0 taken 4056840 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4056840 times.
4056840 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
17910 {
17911 return false;
17912 }
17913
2/2
✓ Branch 0 taken 4047248 times.
✓ Branch 1 taken 9592 times.
4056840 switch(guysbuf[id&0xFFF].type)
17914 {
17915 case eeMANHAN:
17916 case eeMOLD:
17917 case eeLANM:
17918 case eeGLEEOK:
17919 case eeZORA:
17920 case eeLEV:
17921 case eeAQUA:
17922 case eeROCK:
17923 case eeGANON:
17924 case eeTRAP:
17925 case eePROJECTILE:
17926 case eeSPINTILE:
17927 9592 return true;
17928 }
17929
17930 4047248 return false;
17931 4056840 }
17932
17933 2258945 bool canfall(int32_t id)
17934 {
17935
3/4
✓ Branch 0 taken 2258945 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 46 times.
✓ Branch 3 taken 2258899 times.
2258945 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
17936 {
17937 46 return false;
17938 }
17939
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 2258859 times.
✓ Branch 2 taken 40 times.
2258899 switch(guysbuf[id&0xFFF].type)
17940 {
17941 case eeGUY:
17942 {
17943
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(id < eOCTO1S)
17944 40 return false;
17945
17946 switch(guysbuf[id&0xFFF].attributes[9])
17947 {
17948 case 1:
17949 case 2:
17950 return true;
17951
17952 case 0:
17953 case 3:
17954 default:
17955 return false;
17956 }
17957
17958 case eeGHOMA:
17959 case eeDIG:
17960 return false;
17961 }
17962 }
17963
17964
17965
4/4
✓ Branch 0 taken 2250381 times.
✓ Branch 1 taken 8478 times.
✓ Branch 2 taken 180404 times.
✓ Branch 3 taken 2069977 times.
2258859 return !never_in_air(id) && !isflier(id) && !isjumper(id);
17966 2258945 }
17967
17968 60437750 bool enemy::enemycanfall(int32_t id, bool checkgrav) const
17969 {
17970
3/4
✓ Branch 0 taken 60437750 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 89598 times.
✓ Branch 3 taken 60348152 times.
60437750 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
17971 {
17972 89598 return false;
17973 }
17974 //Z_scripterrlog("canfall family is %d:\n", family);
17975 //Z_scripterrlog("canfall gravity is %s:\n", moveflags & move_obeys_grav ? "true" : "false");
17976 //if ( family == eeFIRE && id >= eSTART )
17977 //{
17978 // Z_scripterrlog("eeFire\n");
17979 // return moveflags & move_obeys_grav; //'Other' enemy class, used by scripts. -Z
17980 //}
17981
17982 //In ZQ, eeFIRE is Other(floating) and eeOTHER is 'other'.
17983
17984
3/3
✓ Branch 0 taken 428935 times.
✓ Branch 1 taken 57841740 times.
✓ Branch 2 taken 2077477 times.
60348152 switch(guysbuf[id&0xFFF].type)
17985 {
17986 case eeGUY:
17987 {
17988
1/2
✓ Branch 0 taken 2077477 times.
✗ Branch 1 not taken.
2077477 if(id < eOCTO1S) //screen guys and fires that aren't real enemies, and never fall
17989 2077477 return false;
17990
17991 switch(guysbuf[id&0xFFF].attributes[9]) //I'm unsure what these specify off-hand. Needs better comments. -Z
17992 {
17993 case 1:
17994 case 2:
17995 return true;
17996
17997 case 0:
17998 case 3:
17999 default:
18000 return false;
18001 }
18002
18003 case eeGHOMA:
18004 case eeDIG:
18005 428935 return false;
18006 }
18007 }
18008
18009
2/2
✓ Branch 0 taken 40224377 times.
✓ Branch 1 taken 17617363 times.
57841740 if(!checkgrav) return true;
18010 40224377 return (moveflags & move_obeys_grav);
18011
18012 // if ( isflier(id) || isjumper(id) || never_in_air(id) )
18013 // {
18014 // if ( moveflags & move_obeys_grav ) return true;
18015 // else return false;
18016 // }
18017 // else
18018 // {
18019 // return (moveflags & move_obeys_grav);
18020 // }
18021 //return !never_in_air(id) && !isflier(id) && !isjumper(id);
18022 60437750 }
18023
18024 1278 void addfires()
18025 {
18026
2/2
✓ Branch 0 taken 821 times.
✓ Branch 1 taken 457 times.
1278 if(!get_qr(qr_NOGUYFIRES))
18027 {
18028 2285 auto [dx, dy] = translate_screen_coordinates_to_world(cur_screen);
18029 457 int32_t bs = get_qr(qr_BSZELDA);
18030 914 addguy(dx+(bs? 64: 72),dy+64,gFIRE,-17,false,nullptr);
18031 914 addguy(dx+(bs?176:168),dy+64,gFIRE,-18,false,nullptr);
18032 457 }
18033 1278 }
18034
18035 // This function runs one time for every screen on the first frame of a region being loaded.
18036 // It handles spawning screen guys (not the enemies), item, and room-specific sprites.
18037 38702 static void loadguys(mapscr* scr)
18038 {
18039 38702 int screen = scr->screen;
18040 38702 byte Guy=0;
18041 // When in caves/item rooms, use mSPECIALITEM and ipONETIME2
18042 // Else use mITEM and ipONETIME
18043 38702 int32_t mf = (screen>=128) ? mSPECIALITEM : mITEM;
18044 38702 int32_t onetime = (screen>=128) ? ipONETIME2 : ipONETIME;
18045
18046 38702 mapscr* guyscr = scr;
18047
4/4
✓ Branch 0 taken 906 times.
✓ Branch 1 taken 37796 times.
✓ Branch 2 taken 475 times.
✓ Branch 3 taken 431 times.
38702 if(screen>=128 && DMaps[cur_dmap].flags&dmfGUYCAVES)
18048 {
18049
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 431 times.
431 if(DMaps[cur_dmap].flags&dmfCAVES)
18050 {
18051 431 Guy=special_warp_return_scr->guy;
18052 431 guyscr = special_warp_return_scr;
18053 431 }
18054 431 }
18055 else
18056 {
18057 38271 Guy=scr->guy;
18058
2/2
✓ Branch 0 taken 1669 times.
✓ Branch 1 taken 36602 times.
38271 if (game->get_regionmapping() == REGION_MAPPING_FULL)
18059 36602 mark_visited(screen);
18060 }
18061
18062 119036 auto [dx, dy] = translate_screen_coordinates_to_world(screen);
18063
18064 38702 bool oldguy = get_qr(qr_OLD_GUY_HANDLING);
18065 // The Guy appears if 'Hero is in cave' equals 'Guy is in cave'.
18066
4/4
✓ Branch 0 taken 3872 times.
✓ Branch 1 taken 34830 times.
✓ Branch 2 taken 2550 times.
✓ Branch 3 taken 1322 times.
38702 if(Guy && ((screen>=128) == !!(DMaps[cur_dmap].flags&dmfGUYCAVES)))
18067 {
18068
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1311 times.
1322 if(scr->room==rZELDA)
18069 {
18070 22 addguy(dx+120,dy+72,Guy,-15,true,guyscr);
18071 11 guys.spr(0)->hxofs=1000;
18072 33 addenemy(screen,dx+128,dy+96,eFIRE,-15);
18073 33 addenemy(screen,dx+112,dy+96,eFIRE,-15);
18074 33 addenemy(screen,dx+96,dy+120,eFIRE,-15);
18075 33 addenemy(screen,dx+144,dy+120,eFIRE,-15);
18076 11 return;
18077 }
18078
18079
2/2
✓ Branch 0 taken 1300 times.
✓ Branch 1 taken 11 times.
2611 bool ffire = oldguy
18080
2/2
✓ Branch 0 taken 1271 times.
✓ Branch 1 taken 29 times.
1300 ? (Guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES))
18081 11 : (guyscr->roomflags&RFL_GUYFIRES);
18082
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 1278 times.
1311 if(ffire)
18083 1278 addfires();
18084
18085
2/2
✓ Branch 0 taken 886 times.
✓ Branch 1 taken 425 times.
1311 if(screen>=128)
18086
3/4
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 412 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
438 if(getmapflag(screen, 32) && !(scr->flags9&fBELOWRETURN))
18087 13 Guy=0;
18088
18089
4/6
✓ Branch 0 taken 167 times.
✓ Branch 1 taken 1098 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 45 times.
1311 switch(scr->room)
18090 {
18091 case rSP_ITEM:
18092 case rGRUMBLE:
18093 case rBOMBS:
18094 case rARROWS:
18095 case rSWINDLE:
18096 case rMUPGRADE:
18097 case rLEARNSLASH:
18098 case rTAKEONE:
18099
8/8
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 55 times.
✓ Branch 3 taken 61 times.
✓ Branch 4 taken 63 times.
✓ Branch 5 taken 61 times.
✓ Branch 6 taken 21 times.
✓ Branch 7 taken 42 times.
167 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, mf)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, 32) && !(scr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18100 55 Guy=0;
18101
18102 179 break;
18103
18104 case rREPAIR:
18105 if (get_qr(qr_OLD_DOORREPAIR)) break;
18106 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, mf)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, 32) && !(scr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18107 Guy=0;
18108
18109 break;
18110 case rRP_HC:
18111 if (get_qr(qr_OLD_POTION_OR_HC)) break;
18112 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, mf)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, 32) && !(scr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18113 Guy=0;
18114
18115 break;
18116 case rMONEY:
18117
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (get_qr(qr_OLD_SECRETMONEY)) break;
18118 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, mf)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, 32) && !(scr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18119 Guy=0;
18120
18121 break;
18122
18123 case rTRIFORCE:
18124 {
18125 45 int32_t tc = TriforceCount();
18126
18127
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 34 times.
45 if(get_qr(qr_4TRI))
18128 {
18129
4/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1 times.
11 if((get_qr(qr_3TRI) && tc>=3) || tc>=4)
18130 10 Guy=0;
18131 9 }
18132 else
18133 {
18134
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 33 times.
✓ Branch 3 taken 1 times.
34 if((get_qr(qr_3TRI) && tc>=6) || tc>=8)
18135 33 Guy=0;
18136 }
18137 }
18138 43 break;
18139 }
18140
18141
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 1202 times.
1309 if(Guy)
18142 {
18143
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 1169 times.
1202 if(ffire)
18144 1169 blockpath=true;
18145
18146
2/2
✓ Branch 0 taken 412 times.
✓ Branch 1 taken 790 times.
1202 if(screen<128)
18147 790 sfx(WAV_SCALE);
18148
18149
6/6
✓ Branch 0 taken 474 times.
✓ Branch 1 taken 728 times.
✓ Branch 2 taken 474 times.
✓ Branch 3 taken 728 times.
✓ Branch 4 taken 117 times.
✓ Branch 5 taken 357 times.
2404 addguy(dx+120,dy+64,Guy, (dlevel||BSZ)?-15:startguy[zc_oldrand()&7], true, guyscr);
18150 1202 Hero.Freeze();
18151 1202 }
18152 1309 }
18153
5/6
✓ Branch 0 taken 33908 times.
✓ Branch 1 taken 3472 times.
✓ Branch 2 taken 71 times.
✓ Branch 3 taken 33837 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3472 times.
37380 else if(oldguy ? Guy==gFAIRY : (Guy && (guyscr->roomflags&RFL_ALWAYS_GUY))) // The only Guy that somewhat ignores the "Guys In Caves Only" DMap flag
18154 {
18155 71 sfx(WAV_SCALE);
18156 142 addguy(dx+120,dy+62,gFAIRY,-14,false,guyscr);
18157 71 }
18158
18159 116067 loaditem(scr, dx, dy);
18160
18161 // Collecting a rupee in a '10 Rupees' screen sets the mITEM screen state if
18162 // it doesn't appear in a Cave/Item Cellar, and the mSPECIALITEM screen state if it does.
18163
4/4
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 38670 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 15 times.
38689 if (scr->room==r10RUPIES && !getmapflag(screen, mf))
18164 {
18165
2/2
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 15 times.
165 for(int32_t i=0; i<10; i++)
18166 300 additem(dx+ten_rupies_x[i],dy+ten_rupies_y[i],0,ipBIGRANGE+onetime,-14);
18167 15 }
18168 38700 }
18169
18170 37458 void loadguys()
18171 {
18172
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37458 times.
37458 if (loaded_guys)
18173 return;
18174
18175 37458 loaded_guys = true;
18176 37458 repaircharge = 0;
18177 37458 adjustmagic = false;
18178 37458 learnslash = false;
18179
2/2
✓ Branch 0 taken 112374 times.
✓ Branch 1 taken 37458 times.
149832 for (int32_t i=0; i<3; i++)
18180 {
18181 112374 prices[i] = 0;
18182 112374 }
18183
18184 76160 for_every_base_screen_in_region([&](mapscr* scr, unsigned int region_scr_x, unsigned int region_scr_y) {
18185 38702 get_screen_state(scr->screen).item_state = ScreenItemState::None;
18186 38702 loadguys(scr);
18187 38702 });
18188 37458 }
18189
18190 38708 void loaditem(mapscr* scr, int offx, int offy)
18191 {
18192 38708 int screen = scr->screen;
18193 38708 byte Item = 0;
18194
18195
2/2
✓ Branch 0 taken 37802 times.
✓ Branch 1 taken 906 times.
38708 if(screen<128)
18196 {
18197 37802 Item=scr->item;
18198
18199
4/4
✓ Branch 0 taken 1730 times.
✓ Branch 1 taken 36072 times.
✓ Branch 2 taken 34306 times.
✓ Branch 3 taken 3496 times.
37802 if((!getmapflag(screen, mITEM) || (scr->flags9&fITEMRETURN)) && (scr->hasitem != 0))
18200 {
18201
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 3410 times.
3496 if(scr->flags8&fSECRETITEM)
18202 86 screen_item_set_state(screen, ScreenItemState::WhenTriggerSecrets);
18203
2/2
✓ Branch 0 taken 1274 times.
✓ Branch 1 taken 2136 times.
3410 else if(scr->flags&fITEM)
18204 1274 screen_item_set_state(screen, ScreenItemState::WhenKillEnemies);
18205
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 2020 times.
2136 else if(scr->flags11&efCARRYITEM)
18206 116 screen_item_set_state(screen, ScreenItemState::MustGiveToEnemy); // Will be set to CarriedByEnemy in roaming_item
18207 else
18208 {
18209 2020 int x = scr->itemx;
18210
3/4
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 2005 times.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
2020 int y = scr->flags7&fITEMFALLS && isSideViewGravity() ?
18211 -170 :
18212 2020 scr->itemy+(get_qr(qr_NOITEMOFFSET)?0:1);
18213
3/6
✓ Branch 0 taken 2020 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2020 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2020 times.
✗ Branch 5 not taken.
4040 add_item_for_screen(screen, new item(offx + x, offy + y,
18214
6/10
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 2005 times.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 15 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2005 times.
✗ Branch 9 not taken.
2020 (scr->flags7&fITEMFALLS && !(isSideViewGravity())) ? (zfix)170 : (zfix)0,
18215
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 1908 times.
2020 Item,ipONETIME|ipBIGRANGE|((itemsbuf[Item].type==itype_triforcepiece ||
18216 2020 (scr->flags3&fHOLDITEM)) ? ipHOLDUP : 0) | ((scr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
18217 }
18218 3496 }
18219 37802 }
18220
2/2
✓ Branch 0 taken 431 times.
✓ Branch 1 taken 475 times.
906 else if(!(DMaps[cur_dmap].flags&dmfCAVES))
18221 {
18222
4/6
✓ Branch 0 taken 475 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 469 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 16 times.
491 if((!getmapflag(screen, (screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (special_warp_return_scr->flags9&fBELOWRETURN)) && special_warp_return_scr->room==rSP_ITEM
18223
4/4
✓ Branch 0 taken 163 times.
✓ Branch 1 taken 312 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 147 times.
475 && (screen==128 || !get_qr(qr_ITEMSINPASSAGEWAYS)))
18224 {
18225 163 Item = special_warp_return_scr->catchall;
18226
18227
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 162 times.
163 if(Item)
18228 {
18229 162 int x = scr->itemx;
18230
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
162 int y = scr->flags7&fITEMFALLS && isSideViewGravity() ?
18231 -170 :
18232 162 scr->itemy+(get_qr(qr_NOITEMOFFSET)?0:1);
18233
3/6
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 162 times.
✗ Branch 5 not taken.
324 add_item_for_screen(screen, new item(offx + x, offy + y,
18234
2/10
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 162 times.
✗ Branch 9 not taken.
162 (scr->flags7&fITEMFALLS && !(isSideViewGravity())) ? (zfix)170 : (zfix)0,
18235 162 Item,ipONETIME2|ipBIGRANGE|ipHOLDUP | ((scr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
18236 162 }
18237 163 }
18238 475 }
18239 38708 }
18240
18241 957 void never_return(int32_t screen, int32_t index)
18242 {
18243
2/2
✓ Branch 0 taken 766 times.
✓ Branch 1 taken 191 times.
957 if(!get_qr(qr_KILLALL))
18244 191 goto doit;
18245
18246
2/2
✓ Branch 0 taken 2292 times.
✓ Branch 1 taken 329 times.
2621 for(int32_t i=0; i<guys.Count(); i++)
18247
4/4
✓ Branch 0 taken 980 times.
✓ Branch 1 taken 1312 times.
✓ Branch 2 taken 543 times.
✓ Branch 3 taken 437 times.
2292 if(((((enemy*)guys.spr(i))->d->flags)&guy_never_return) && i!=index)
18248 {
18249 437 goto dontdoit;
18250 329 }
18251
18252 doit:
18253 520 setmapflag(get_scr(screen), mNEVERRET);
18254 dontdoit:
18255 957 return;
18256 }
18257
18258 67200 bool slowguy(int32_t id)
18259 {
18260
2/4
✓ Branch 0 taken 67200 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 67200 times.
67200 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
18261 {
18262 return false;
18263 }
18264
18265 67200 id = id&0xFFF;
18266
18267
2/2
✓ Branch 0 taken 56866 times.
✓ Branch 1 taken 10334 times.
67200 switch(id)
18268 {
18269 case eOCTO1S:
18270 case eOCTO2S:
18271 case eOCTO1F:
18272 case eOCTO2F:
18273 case eLEV1:
18274 case eLEV2:
18275 case eROCK:
18276 case eBOULDER:
18277 10334 return true;
18278 }
18279
18280 56866 return false;
18281 67200 }
18282
18283 87075 static bool ok2add(mapscr* scr, int32_t id)
18284 {
18285
2/4
✓ Branch 0 taken 87075 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 87075 times.
87075 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
18286 {
18287 return false;
18288 }
18289
18290 87075 id = id&0xFFF;
18291
18292
4/4
✓ Branch 0 taken 829 times.
✓ Branch 1 taken 86246 times.
✓ Branch 2 taken 464 times.
✓ Branch 3 taken 365 times.
87075 if(getmapflag(scr, mNEVERRET) && (guysbuf[id].flags & guy_never_return))
18293 464 return false;
18294
18295
4/4
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 85966 times.
✓ Branch 2 taken 380 times.
✓ Branch 3 taken 201 times.
86611 switch(guysbuf[id].type)
18296 {
18297 // I added a special case for shooters because having traps on the same screen
18298 // was preventing them from spawning due to TMPNORET. This means they will
18299 // never stay dead, though, so it may not be the best solution. - Saf
18300 case eePROJECTILE:
18301 380 return true;
18302
18303
18304 case eeDIG:
18305 {
18306
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✓ Branch 2 taken 75 times.
201 switch(guysbuf[id].attributes[9])
18307 {
18308 case 1:
18309
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 47 times.
126 if(!get_qr(qr_NOTMPNORET))
18310 79 return !getmapflag(scr, mTMPNORET);
18311
18312 47 return true;
18313
18314 75 case 0:
18315 default:
18316 75 return true;
18317 }
18318 }
18319 case eeGANON:
18320 case eeTRAP:
18321
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
128 if ((guysbuf[id].type == eeGANON && !get_qr(qr_CAN_PLACE_GANON))
18322
4/4
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 64 times.
✓ Branch 3 taken 64 times.
64 || (guysbuf[id].type == eeTRAP && !get_qr(qr_CAN_PLACE_TRAPS))) return false;
18323 [[fallthrough]];
18324 default:
18325
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85966 times.
85966 if (guysbuf[id].flags&guy_ignoretmpnr) return true;
18326 85966 break;
18327 }
18328
18329
2/2
✓ Branch 0 taken 20978 times.
✓ Branch 1 taken 64988 times.
85966 if(!get_qr(qr_NOTMPNORET))
18330 64988 return !getmapflag(scr, mTMPNORET);
18331
18332 20978 return true;
18333 87075 }
18334
18335 1668715 static void activate_fireball_statue(const rpos_handle_t& rpos_handle)
18336 {
18337
3/4
✓ Branch 0 taken 289021 times.
✓ Branch 1 taken 1379694 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 289021 times.
1668715 if (!(rpos_handle.scr->flags11&efFIREBALLS) || statueID<0)
18338 {
18339 1379694 return;
18340 }
18341
18342 289021 int32_t ctype = rpos_handle.ctype();
18343
6/6
✓ Branch 0 taken 287513 times.
✓ Branch 1 taken 1508 times.
✓ Branch 2 taken 286198 times.
✓ Branch 3 taken 1315 times.
✓ Branch 4 taken 1213 times.
✓ Branch 5 taken 284985 times.
289021 if (ctype != cL_STATUE && ctype != cR_STATUE && ctype != cC_STATUE) return;
18344
18345 12108 auto [x, y] = rpos_handle.xy();
18346
18347 4036 int32_t cx=-1000, cy=-1000;
18348
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4036 times.
4036 if(!isfixedtogrid(statueID))
18349 {
18350
2/2
✓ Branch 0 taken 1508 times.
✓ Branch 1 taken 2528 times.
4036 if(ctype==cL_STATUE)
18351 {
18352 1508 cx=x+4;
18353 1508 cy=y+7;
18354 1508 }
18355
2/2
✓ Branch 0 taken 1315 times.
✓ Branch 1 taken 1213 times.
2528 else if(ctype==cR_STATUE)
18356 {
18357 1315 cx=x-8;
18358 1315 cy=y-1;
18359 1315 }
18360
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1213 times.
1213 else if(ctype==cC_STATUE)
18361 {
18362 1213 cx=x;
18363 1213 cy=y;
18364 1213 }
18365 4036 }
18366 else if(ctype==cL_STATUE || ctype==cR_STATUE || ctype==cC_STATUE)
18367 {
18368 cx=x;
18369 cy=y;
18370 }
18371
18372
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4036 times.
4036 if(cx!=-1000) // No point creating it if this is false
18373 {
18374
2/2
✓ Branch 0 taken 9754 times.
✓ Branch 1 taken 4032 times.
13786 for(int32_t j=0; j<guys.Count(); j++)
18375 {
18376
4/4
✓ Branch 0 taken 1698 times.
✓ Branch 1 taken 8056 times.
✓ Branch 2 taken 1694 times.
✓ Branch 3 taken 4 times.
9754 if((int32_t(guys.spr(j)->x)==cx)&&(int32_t(guys.spr(j)->y)==cy))
18377 {
18378
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if((guys.spr(j)->id&0xFFF) == statueID) // There's already a matching enemy here!
18379 4 return; // No point deleting it. A script might be toying with it in some way.
18380 else
18381 guys.del(j);
18382 }
18383 9750 }
18384
18385 4032 addenemy(rpos_handle.screen, cx, cy, statueID, !isfixedtogrid(statueID) ? 24 : 0);
18386 4032 }
18387 1668715 }
18388
18389 35995 static void activate_fireball_statues(mapscr* scr)
18390 {
18391
2/2
✓ Branch 0 taken 34575 times.
✓ Branch 1 taken 1420 times.
35995 if (!(scr->flags11&efFIREBALLS))
18392 {
18393 34575 return;
18394 }
18395
18396 251340 for_every_rpos_in_screen_layer0(scr, [&](const rpos_handle_t& rpos_handle) {
18397 249920 activate_fireball_statue(rpos_handle);
18398 249920 });
18399 35995 }
18400
18401 36678 void load_default_enemies(mapscr* scr)
18402 {
18403 36678 int screen = scr->screen;
18404 42143 auto [dx, dy] = translate_screen_coordinates_to_world(screen);
18405
18406 36678 wallm_load_clk=frame-80;
18407
18408
2/2
✓ Branch 0 taken 34782 times.
✓ Branch 1 taken 1896 times.
36678 if(scr->flags11&efZORA)
18409 {
18410
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1896 times.
1896 if(zoraID>=0)
18411 5688 addenemy(screen, dx - 16, dy - 16, zoraID, 0);
18412 1896 }
18413
18414
2/2
✓ Branch 0 taken 36500 times.
✓ Branch 1 taken 178 times.
36678 if(scr->flags11&efTRAP4)
18415 {
18416
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 178 times.
178 if(cornerTrapID>=0)
18417 {
18418 534 addenemy(screen, dx + 32, dy + 32, cornerTrapID, -14);
18419 534 addenemy(screen, dx + 208, dy + 32, cornerTrapID, -14);
18420 534 addenemy(screen, dx + 32, dy + 128, cornerTrapID, -14);
18421 534 addenemy(screen, dx + 208, dy + 128, cornerTrapID, -14);
18422 178 }
18423 178 }
18424
18425 6492006 for_every_rpos_in_screen_layer0(scr, [&](const rpos_handle_t& rpos_handle) {
18426 6455328 int32_t ctype = rpos_handle.ctype();
18427 6455328 int32_t cflag = rpos_handle.sflag();
18428 6455328 int32_t cflag_i = rpos_handle.cflag();
18429
18430
4/6
✓ Branch 0 taken 6455328 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6454958 times.
✓ Branch 3 taken 370 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6454958 times.
6455328 if(ctype==cTRAP_H || cflag==mfTRAP_H || cflag_i==mfTRAP_H)
18431 {
18432 370 auto [x, y] = rpos_handle.xy();
18433
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 360 times.
370 if(trapLOSHorizontalID>=0)
18434 1080 addenemy(screen, x, y, trapLOSHorizontalID, -14);
18435 370 }
18436
4/6
✓ Branch 0 taken 6454958 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6454736 times.
✓ Branch 3 taken 222 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6454736 times.
6454958 else if(ctype==cTRAP_V || cflag==mfTRAP_V || cflag_i==mfTRAP_V)
18437 {
18438 222 auto [x, y] = rpos_handle.xy();
18439
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 222 times.
222 if(trapLOSVerticalID>=0)
18440 666 addenemy(screen, x, y, trapLOSVerticalID, -14);
18441 222 }
18442
4/6
✓ Branch 0 taken 6454736 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6454458 times.
✓ Branch 3 taken 278 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6454458 times.
6454736 else if(ctype==cTRAP_4 || cflag==mfTRAP_4 || cflag_i==mfTRAP_4)
18443 {
18444 278 auto [x, y] = rpos_handle.xy();
18445
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 278 times.
278 if(trapLOS4WayID>=0)
18446 {
18447
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 278 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 278 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 278 times.
834 if(addenemy(screen, x, y, trapLOS4WayID, -14))
18448 278 guys.spr(guys.Count()-1)->dummy_int[1]=2;
18449 278 }
18450 278 }
18451
4/6
✓ Branch 0 taken 6454458 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6454022 times.
✓ Branch 3 taken 436 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6454022 times.
6454458 else if(ctype==cTRAP_LR || cflag==mfTRAP_LR || cflag_i==mfTRAP_LR)
18452 {
18453 436 auto [x, y] = rpos_handle.xy();
18454
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 436 times.
436 if(trapConstantHorizontalID>=0)
18455 1308 addenemy(screen, x, y, trapConstantHorizontalID, -14);
18456 436 }
18457
4/6
✓ Branch 0 taken 6454022 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6453565 times.
✓ Branch 3 taken 457 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6453565 times.
6454022 else if(ctype==cTRAP_UD || cflag==mfTRAP_UD || cflag_i==mfTRAP_UD)
18458 {
18459 457 auto [x, y] = rpos_handle.xy();
18460
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
457 if(trapConstantVerticalID>=0)
18461 1371 addenemy(screen, x, y, trapConstantVerticalID, -14);
18462 457 }
18463
18464
1/2
✓ Branch 0 taken 6455328 times.
✗ Branch 1 not taken.
6455328 if(ctype==cSPINTILE1)
18465 {
18466 awaken_spinning_tile(rpos_handle);
18467 }
18468 6455328 });
18469
18470
2/2
✓ Branch 0 taken 36622 times.
✓ Branch 1 taken 56 times.
36678 if(scr->flags11&efTRAP2)
18471 {
18472
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 if(centerTrapID>=-1)
18473 {
18474
1/2
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
56 if(addenemy(screen, 64, 80, centerTrapID, -14))
18475 56 guys.spr(guys.Count()-1)->dummy_int[1]=1;
18476
18477
1/2
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
56 if(addenemy(screen, 176, 80, centerTrapID, -14))
18478 56 guys.spr(guys.Count()-1)->dummy_int[1]=1;
18479 56 }
18480 56 }
18481
18482
2/2
✓ Branch 0 taken 36595 times.
✓ Branch 1 taken 83 times.
36678 if(scr->flags11&efROCKS)
18483 {
18484
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 83 times.
83 if(rockID>=0)
18485 {
18486 166 addenemy(screen, dx + (zc_oldrand()&0xF0), 0, rockID, 0);
18487 166 addenemy(screen, dx + (zc_oldrand()&0xF0), 0, rockID, 0);
18488 166 addenemy(screen, dx + (zc_oldrand()&0xF0), 0, rockID, 0);
18489 83 }
18490 83 }
18491 36678 }
18492
18493 #define SLOPE_STAGE_COMBOS 0
18494 #define SLOPE_STAGE_FFCS 1
18495 #define SLOPE_STAGE_COMBOS_BORDERING_SCREENS 2
18496
18497 22840025 static slope_id_t create_slope_id(int stage, int arg1, int arg2)
18498 {
18499
2/2
✓ Branch 0 taken 4658462 times.
✓ Branch 1 taken 18181563 times.
22840025 if (stage == SLOPE_STAGE_COMBOS)
18500 18181563 return (region_num_rpos*arg1)+arg2;
18501
2/2
✓ Branch 0 taken 4517266 times.
✓ Branch 1 taken 141196 times.
4658462 if (stage == SLOPE_STAGE_FFCS)
18502 4517266 return (region_num_rpos*7)+arg1;
18503
1/2
✓ Branch 0 taken 141196 times.
✗ Branch 1 not taken.
141196 if (stage == SLOPE_STAGE_COMBOS_BORDERING_SCREENS)
18504 141196 return (region_num_rpos*7 + MAX_FFCID+1)+arg1*7*(16 * 2 + 11 * 2) + arg2;
18505 // TODO: what about FFCs from bordering screens?
18506
18507 assert(false);
18508 return 0;
18509 22840025 }
18510
18511 18181563 void update_slope_combopos(const rpos_handle_t& rpos_handle)
18512 {
18513 18181563 mapscr* s = rpos_handle.scr;
18514 18181563 auto& cmb = rpos_handle.combo();
18515
18516 18181563 auto id = create_slope_id(SLOPE_STAGE_COMBOS, rpos_handle.layer, (int)rpos_handle.rpos);
18517 18181563 auto it = slopes.find(id);
18518
18519 18181563 bool wasSlope = it!=slopes.end();
18520 18181563 bool isSlope = cmb.type == cSLOPE;
18521
18522
3/4
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 18181427 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 136 times.
18181563 if(isSlope && !wasSlope)
18523 {
18524 272 auto [x, y] = rpos_handle.xy();
18525 272 slopes.try_emplace(id, &(s->data[rpos_handle.pos]), nullptr, -1, x, y);
18526 136 }
18527
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18181427 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
18181427 else if(wasSlope && !isSlope)
18528 {
18529 slopes.erase(it);
18530 }
18531 18181563 }
18532
18533 141196 static void update_slope_combopos_bordering_screen(int dir, int slope_count, int cid, bool is_slope, int offx, int offy)
18534 {
18535 141196 auto id = create_slope_id(SLOPE_STAGE_COMBOS_BORDERING_SCREENS, dir, slope_count);
18536 141196 auto it = slopes.find(id);
18537
18538 141196 bool wasSlope = it!=slopes.end();
18539 141196 bool isSlope = is_slope;
18540
18541
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 141196 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
141196 if(isSlope && !wasSlope)
18542 {
18543 static std::vector<word> TMP;
18544 int num_border_combos = cur_region.screen_width*16 * 2 + cur_region.screen_height*11 * 2;
18545 TMP.resize(num_border_combos * 7 * 4);
18546
18547 int tmp_index = id-create_slope_id(SLOPE_STAGE_COMBOS_BORDERING_SCREENS,0,0);
18548 TMP[tmp_index] = cid;
18549 slopes.try_emplace(id, &TMP[tmp_index], nullptr, -1, offx, offy);
18550 }
18551
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 141196 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
141196 else if(wasSlope && !isSlope)
18552 {
18553 slopes.erase(it);
18554 }
18555 141196 }
18556
18557 // Load a single column or row from a nearby screen, and load its slopes.
18558 3884 static void handle_slope_combopos_bordering_screen(int initial_screen, int dir)
18559 {
18560 55866 auto [map, screen] = nextscr2(cur_map, initial_screen, dir);
18561
2/2
✓ Branch 0 taken 3713 times.
✓ Branch 1 taken 171 times.
3884 if (map == -1)
18562 171 return;
18563
18564 3713 int offx = 0;
18565 3713 int offy = 0;
18566
2/2
✓ Branch 0 taken 2800 times.
✓ Branch 1 taken 913 times.
3713 if (dir == up)
18567 913 offy = -16;
18568
2/2
✓ Branch 0 taken 862 times.
✓ Branch 1 taken 1938 times.
2800 else if (dir == down)
18569 862 offy = world_h;
18570
2/2
✓ Branch 0 taken 968 times.
✓ Branch 1 taken 970 times.
1938 else if (dir == left)
18571 968 offx = -16;
18572
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 970 times.
970 else if (dir == right)
18573 970 offx = world_w;
18574
18575
2/2
✓ Branch 0 taken 3713 times.
✓ Branch 1 taken 25991 times.
29704 for (int layer = 0; layer < 7; layer++)
18576 {
18577 51982 auto scr = load_temp_mapscr_and_apply_secrets(map, screen, layer - 1, true, false);
18578
2/2
✓ Branch 0 taken 10526 times.
✓ Branch 1 taken 15465 times.
25991 if (!scr) continue;
18579
18580 10526 int slope_count = layer * (16*2);
18581
18582
4/4
✓ Branch 0 taken 7826 times.
✓ Branch 1 taken 2700 times.
✓ Branch 2 taken 2744 times.
✓ Branch 3 taken 5082 times.
10526 if (dir == left || dir == right)
18583 {
18584 5444 int x = dir == left ? 15 : 0;
18585
2/2
✓ Branch 0 taken 59884 times.
✓ Branch 1 taken 5444 times.
65328 for (int y = 0; y < 11; y++)
18586 {
18587 59884 int pos = y * 16 + x;
18588 59884 int cid = scr->data[pos];
18589 59884 bool is_slope = combobuf[cid].type == cSLOPE;
18590
1/2
✓ Branch 0 taken 59884 times.
✗ Branch 1 not taken.
59884 update_slope_combopos_bordering_screen(dir, slope_count++, cid, is_slope, offx, offy + y*16);
18591 59884 }
18592 5444 }
18593
3/4
✓ Branch 0 taken 2437 times.
✓ Branch 1 taken 2645 times.
✓ Branch 2 taken 2437 times.
✗ Branch 3 not taken.
5082 else if (dir == up || dir == down)
18594 {
18595 5082 int y = dir == up ? 10 : 0;
18596
2/2
✓ Branch 0 taken 81312 times.
✓ Branch 1 taken 5082 times.
86394 for (int x = 0; x < 16; x++)
18597 {
18598 81312 int pos = y * 16 + x;
18599 81312 int cid = scr->data[pos];
18600 81312 bool is_slope = combobuf[cid].type == cSLOPE;
18601
1/2
✓ Branch 0 taken 81312 times.
✗ Branch 1 not taken.
81312 update_slope_combopos_bordering_screen(dir, slope_count++, cid, is_slope, offx + x*16, offy);
18602 81312 }
18603 5082 }
18604
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 15465 times.
✓ Branch 2 taken 10526 times.
25991 }
18605 3884 }
18606
18607 37530 void update_slope_comboposes()
18608 {
18609 16800298 for_every_rpos([&](const rpos_handle_t& rpos_handle) {
18610 16762768 update_slope_combopos(rpos_handle);
18611 16762768 });
18612
18613
2/2
✓ Branch 0 taken 36559 times.
✓ Branch 1 taken 971 times.
37530 if (Hero.sideview_mode())
18614 {
18615 1942 for_every_base_screen_in_region([&](mapscr* scr, unsigned int region_scr_x, unsigned int region_scr_y) {
18616
2/2
✓ Branch 0 taken 3884 times.
✓ Branch 1 taken 971 times.
4855 for (int dir = up; dir <= right; dir++)
18617 3884 handle_slope_combopos_bordering_screen(scr->screen, dir);
18618 971 });
18619 971 }
18620
18621 37530 update_slopes();
18622 37530 }
18623
18624 // Everything that must be done before we change a screen's combo to another combo, or a combo's type to another type.
18625 1418795 void screen_combo_modify_preroutine(const rpos_handle_t& rpos_handle)
18626 {
18627 1418795 delete_fireball_shooter(rpos_handle);
18628 1418795 }
18629
18630 //Placeholder in case we need it.
18631 void screen_ffc_modify_preroutine(const ffc_handle_t& ffc_handle)
18632 {
18633 return;
18634 }
18635
18636 // Everything that must be done after we change a screen's combo to another combo. -L
18637 1418795 void screen_combo_modify_postroutine(const rpos_handle_t& rpos_handle)
18638 {
18639 1418795 rpos_handle.scr->valid |= mVALID;
18640 1418795 activate_fireball_statue(rpos_handle);
18641
18642
2/2
✓ Branch 0 taken 1418701 times.
✓ Branch 1 taken 94 times.
1418795 if(rpos_handle.ctype()==cSPINTILE1)
18643 {
18644 94 awaken_spinning_tile(rpos_handle);
18645 94 }
18646
18647 1418795 update_slope_combopos(rpos_handle);
18648 1418795 }
18649
18650 4517266 void screen_ffc_modify_postroutine(const ffc_handle_t& ffc_handle)
18651 {
18652 4517266 ffcdata* ff = ffc_handle.ffc;
18653 4517266 auto& cmb = ffc_handle.combo();
18654
18655 4517266 auto id = create_slope_id(SLOPE_STAGE_FFCS, ffc_handle.id, -1);
18656 4517266 auto it = slopes.find(id);
18657
18658 4517266 bool wasSlope = it!=slopes.end();
18659
1/2
✓ Branch 0 taken 4517266 times.
✗ Branch 1 not taken.
4517266 bool isSlope = cmb.type == cSLOPE && !(ff->flags&ffc_changer);
18660
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4517266 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4517266 if(isSlope && !wasSlope)
18661 {
18662 slopes.try_emplace(id, nullptr, ff, ffc_handle.id);
18663 }
18664
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4517266 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4517266 else if(wasSlope && !isSlope)
18665 {
18666 slopes.erase(it);
18667 }
18668
18669 4517266 ffc_handle.scr->ffcCountMarkDirty();
18670 4517266 }
18671
18672 4414 void screen_combo_modify_pre(int32_t cid)
18673 {
18674 2813022 for_every_rpos([&](const rpos_handle_t& rpos_handle) {
18675
2/2
✓ Branch 0 taken 2803413 times.
✓ Branch 1 taken 5195 times.
2808608 if (rpos_handle.data() == cid)
18676 {
18677 5195 screen_combo_modify_preroutine(rpos_handle);
18678 5195 }
18679 2808608 });
18680 4414 }
18681 4414 void screen_combo_modify_post(int32_t cid)
18682 {
18683 4414 combo_caches::refresh(cid);
18684
18685 2813022 for_every_rpos([&](const rpos_handle_t& rpos_handle) {
18686
2/2
✓ Branch 0 taken 2803413 times.
✓ Branch 1 taken 5195 times.
2808608 if (rpos_handle.data() == cid)
18687 {
18688 5195 screen_combo_modify_postroutine(rpos_handle);
18689 5195 }
18690 2808608 });
18691
18692 144186 for_every_ffc([&](const ffc_handle_t& ffc_handle) {
18693
2/2
✓ Branch 0 taken 139714 times.
✓ Branch 1 taken 58 times.
139772 if (ffc_handle.data() == cid)
18694 {
18695 58 screen_ffc_modify_postroutine(ffc_handle);
18696 58 }
18697 139772 });
18698 4414 }
18699
18700 94 void awaken_spinning_tile(const rpos_handle_t& rpos_handle)
18701 {
18702 94 int cid = rpos_handle.data();
18703 94 int cset = rpos_handle.cset();
18704 282 auto [x, y] = rpos_handle.xy();
18705
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 94 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 94 times.
282 addenemy(rpos_handle.screen, x, y, (cset<<12)+eSPINTILE1, combobuf[cid].o_tile + zc_max(1,combobuf[cid].frames));
18706 94 }
18707
18708 // It stands for next_side_pos
18709 // moves sle_x and sle_y to the next position
18710 11464 void nsp(bool random)
18711 {
18712
2/2
✓ Branch 0 taken 3261 times.
✓ Branch 1 taken 8203 times.
11464 if(random)
18713 {
18714
2/2
✓ Branch 0 taken 1634 times.
✓ Branch 1 taken 1627 times.
3261 if(zc_oldrand()%2)
18715 {
18716 1634 sle_x = (zc_oldrand()%2) ? 0 : 240;
18717 1634 sle_y = (zc_oldrand()%10)*16;
18718 1634 }
18719 else
18720 {
18721 1627 sle_y = (zc_oldrand()%2) ? 0 : 160;
18722 1627 sle_x = (zc_oldrand()%15)*16;
18723 }
18724
18725 3261 return;
18726 }
18727
18728
2/2
✓ Branch 0 taken 6168 times.
✓ Branch 1 taken 2035 times.
8203 if(sle_x==0)
18729 {
18730
2/2
✓ Branch 0 taken 1855 times.
✓ Branch 1 taken 180 times.
2035 if(sle_y<160)
18731 1855 sle_y+=16;
18732 else
18733 180 sle_x+=16;
18734 2035 }
18735
2/2
✓ Branch 0 taken 2596 times.
✓ Branch 1 taken 3572 times.
6168 else if(sle_y==160)
18736 {
18737
2/2
✓ Branch 0 taken 2430 times.
✓ Branch 1 taken 166 times.
2596 if(sle_x<240)
18738 2430 sle_x+=16;
18739 else
18740 166 sle_y-=16;
18741 2596 }
18742
2/2
✓ Branch 0 taken 1552 times.
✓ Branch 1 taken 2020 times.
3572 else if(sle_x==240)
18743 {
18744
2/2
✓ Branch 0 taken 1404 times.
✓ Branch 1 taken 148 times.
1552 if(sle_y>0)
18745 1404 sle_y-=16;
18746 else
18747 148 sle_x-=16;
18748 1552 }
18749
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2020 times.
2020 else if(sle_y==0)
18750 {
18751
1/2
✓ Branch 0 taken 2020 times.
✗ Branch 1 not taken.
2020 if(sle_x>0)
18752 2020 sle_x-=16;
18753 else
18754 sle_y+=16;
18755 2020 }
18756 11464 }
18757
18758 // moves sle_x and sle_y to the next available position
18759 // returns the direction the enemy should face
18760 2429 int32_t next_side_pos(int32_t screen, bool random)
18761 {
18762 bool blocked;
18763 2429 int32_t c=0;
18764 25357 auto [offx, offy] = translate_screen_coordinates_to_world(screen);
18765
18766 2429 do
18767 {
18768
2/2
✓ Branch 0 taken 131 times.
✓ Branch 1 taken 11333 times.
11464 nsp(c>35 ? false : random);
18769 22928 int x = sle_x + offx;
18770 22928 int y = sle_y + offy;
18771
4/4
✓ Branch 0 taken 2447 times.
✓ Branch 1 taken 9017 times.
✓ Branch 2 taken 19 times.
✓ Branch 3 taken 2428 times.
13892 blocked = _walkflag(x,y,2) || _walkflag(x,y+8,2) ||
18772
1/2
✓ Branch 0 taken 2428 times.
✗ Branch 1 not taken.
2428 (combo_class_buf[COMBOTYPE(x,y)].block_enemies ||
18773
2/4
✓ Branch 0 taken 2428 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2428 times.
✗ Branch 3 not taken.
2428 MAPFLAG(x,y) == mfNOENEMY || MAPCOMBOFLAG(x,y)==mfNOENEMY ||
18774
2/4
✓ Branch 0 taken 2428 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2428 times.
2428 MAPFLAG(x,y) == mfNOGROUNDENEMY || MAPCOMBOFLAG(x,y)==mfNOGROUNDENEMY ||
18775 2428 iswaterex_z3(MAPCOMBO(x,y), -1, x, y, true));
18776
18777
2/2
✓ Branch 0 taken 11463 times.
✓ Branch 1 taken 1 times.
11464 if(++c>50)
18778 1 return -1;
18779
2/2
✓ Branch 0 taken 9035 times.
✓ Branch 1 taken 2428 times.
11463 }
18780 11463 while(blocked);
18781
18782 2428 int32_t dir=0;
18783
18784
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 736 times.
2428 if(sle_x==0) dir=right;
18785
18786
2/2
✓ Branch 0 taken 1859 times.
✓ Branch 1 taken 569 times.
2428 if(sle_y==0) dir=down;
18787
18788
2/2
✓ Branch 0 taken 1720 times.
✓ Branch 1 taken 708 times.
2428 if(sle_x==240) dir=left;
18789
18790
1/2
✓ Branch 0 taken 2428 times.
✗ Branch 1 not taken.
2428 if(sle_y==168) dir=up;
18791
18792 2428 return dir;
18793 2429 }
18794
18795 bool can_side_load(int32_t id)
18796 {
18797 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
18798 {
18799 return false;
18800 }
18801
18802 id = id&0xFFF;
18803
18804 switch(guysbuf[id].type)
18805 {
18806 case eeTEK:
18807 case eeLEV:
18808 case eeAQUA:
18809 case eeDONGO:
18810 case eeMANHAN:
18811 case eeGLEEOK:
18812 case eeDIG:
18813 case eeGHOMA:
18814 case eeLANM:
18815 case eePATRA:
18816 case eeGANON:
18817 case eePROJECTILE:
18818 return false;
18819 break;
18820 }
18821
18822 return true;
18823 }
18824
18825 bool enemy_spawning_has_checked_been_here;
18826 static bool enemy_spawning_has_been_here;
18827
18828 36678 static bool check_if_recently_visited()
18829 {
18830
2/2
✓ Branch 0 taken 522 times.
✓ Branch 1 taken 36156 times.
36678 if (enemy_spawning_has_checked_been_here)
18831 522 return enemy_spawning_has_been_here;
18832
18833 36156 int mi = mapind(cur_map, cur_screen);
18834
18835 36156 enemy_spawning_has_been_here = false;
18836
2/2
✓ Branch 0 taken 216936 times.
✓ Branch 1 taken 36156 times.
253092 for (int i = 0; i < 6; i++)
18837
2/2
✓ Branch 0 taken 206777 times.
✓ Branch 1 taken 10159 times.
227095 if (visited[i] == mi)
18838 10159 enemy_spawning_has_been_here = true;
18839
18840
2/2
✓ Branch 0 taken 10159 times.
✓ Branch 1 taken 25997 times.
36156 if (!enemy_spawning_has_been_here)
18841 {
18842 25997 visited[vhead] = mi; //If not, it adds it to the array,
18843 25997 vhead = (vhead+1)%6; //which overrides one of the others, and then moves onto the next.
18844 25997 }
18845
18846 36156 enemy_spawning_has_checked_been_here = true;
18847 36156 return enemy_spawning_has_been_here;
18848 36678 }
18849
18850 static std::array<bool, MAPSCRS> script_sle;
18851
18852 static int32_t sle_pattern = 0;
18853 static void script_side_load_enemies(mapscr* scr)
18854 {
18855 if (script_sle[scr->screen] || sle_clk) return;
18856
18857 sle_cnt = 0;
18858 while(sle_cnt<10 && scr->enemy[sle_cnt]!=0)
18859 ++sle_cnt;
18860 script_sle[scr->screen] = true;
18861 sle_pattern = scr->pattern;
18862 sle_clk = 0;
18863 }
18864
18865 54516 static void side_load_enemies(mapscr* scr)
18866 {
18867 54516 int screen = scr->screen;
18868
18869
3/4
✓ Branch 0 taken 683 times.
✓ Branch 1 taken 53833 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 683 times.
54516 if (sle_clk==0 && !script_sle[scr->screen])
18870 {
18871 683 sle_pattern = scr->pattern;
18872 683 sle_cnt = 0;
18873 683 int32_t guycnt = 0;
18874
18875 683 int mi = mapind(cur_map, screen);
18876 683 bool reload=true;
18877 683 bool unbeatablereload = true;
18878
18879 683 load_default_enemies(scr);
18880
18881 683 bool beenhere = check_if_recently_visited();
18882
4/4
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 480 times.
✓ Branch 2 taken 161 times.
✓ Branch 3 taken 42 times.
683 if (beenhere && game->guys[mi] == 0)
18883 {
18884 42 sle_cnt=0;
18885 42 reload=false;
18886 42 }
18887
18888
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 641 times.
683 if(reload)
18889 {
18890 641 sle_cnt = game->guys[mi];
18891
18892
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 641 times.
✓ Branch 2 taken 420 times.
✓ Branch 3 taken 221 times.
641 if((get_qr(qr_NO_LEAVE_ONE_ENEMY_ALIVE_TRICK) && !beenhere)
18893 641 || sle_cnt==0)
18894 {
18895
4/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1272 times.
✓ Branch 2 taken 1054 times.
✓ Branch 3 taken 221 times.
1275 while(sle_cnt<10 && scr->enemy[sle_cnt]!=0)
18896 1054 ++sle_cnt;
18897 221 }
18898
3/4
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 161 times.
✓ Branch 2 taken 480 times.
✗ Branch 3 not taken.
641 if (!beenhere && get_qr(qr_UNBEATABLES_DONT_KEEP_DEAD))
18899 {
18900 for(int32_t i = 0; i<sle_cnt && scr->enemy[i]>0; i++)
18901 {
18902 if (!(guysbuf[scr->enemy[i]].flags & guy_doesnt_count))
18903 {
18904 unbeatablereload = false;
18905 }
18906 }
18907 if (unbeatablereload)
18908 {
18909 while(sle_cnt<10 && scr->enemy[sle_cnt]!=0)
18910 {
18911 ++sle_cnt;
18912 }
18913 }
18914 }
18915 641 }
18916
18917
3/4
✓ Branch 0 taken 652 times.
✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 652 times.
683 if((get_qr(qr_ALWAYSRET)) || (scr->flags3&fENEMIESRETURN))
18918 {
18919 31 sle_cnt = 0;
18920
18921
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✓ Branch 2 taken 108 times.
✓ Branch 3 taken 31 times.
139 while(sle_cnt<10 && scr->enemy[sle_cnt]!=0)
18922 108 ++sle_cnt;
18923 31 }
18924
1/2
✓ Branch 0 taken 683 times.
✗ Branch 1 not taken.
683 if(getmapflag(scr, mNO_ENEMIES_RETURN))
18925 sle_cnt = 0;
18926
18927
2/2
✓ Branch 0 taken 2446 times.
✓ Branch 1 taken 683 times.
3129 for(int32_t i=0; i<sle_cnt; i++)
18928 2446 ++guycnt;
18929
18930 683 game->guys[mi] = guycnt;
18931 683 }
18932
18933
2/2
✓ Branch 0 taken 52087 times.
✓ Branch 1 taken 2429 times.
54516 if((++sle_clk+8)%24 == 0)
18934 {
18935 2429 int32_t dir = next_side_pos(screen, sle_pattern==pSIDESR);
18936 6819 auto [x, y] = translate_screen_coordinates_to_world(screen, sle_x, sle_y);
18937
18938
6/6
✓ Branch 0 taken 2428 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 233 times.
✓ Branch 3 taken 2195 times.
✓ Branch 4 taken 233 times.
✓ Branch 5 taken 2195 times.
2429 if(dir==-1 || tooclose(x,y,32))
18939 {
18940 234 return;
18941 }
18942
18943 2195 int32_t enemy_slot=guys.Count();
18944
18945
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2195 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2195 times.
2195 while(sle_cnt > 0 && !ok2add(scr, scr->enemy[sle_cnt-1]))
18946 sle_cnt--;
18947
18948
1/2
✓ Branch 0 taken 2195 times.
✗ Branch 1 not taken.
2195 if(sle_cnt > 0)
18949 {
18950
3/6
✓ Branch 0 taken 2195 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2195 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2195 times.
✗ Branch 5 not taken.
6585 if(addenemy(screen, x,y,scr->enemy[--sle_cnt],0))
18951 {
18952
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2195 times.
2195 if (((enemy*)guys.spr(enemy_slot))->type != eeTEK)
18953 {
18954 2195 guys.spr(enemy_slot)->dir = dir;
18955 2195 }
18956
1/2
✓ Branch 0 taken 2195 times.
✗ Branch 1 not taken.
2195 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
18957 {
18958 if (!FFCore.system_suspend[susptNPCSCRIPTS])
18959 {
18960 guys.spr(enemy_slot)->run_script(MODE_NORMAL);
18961 ((enemy*)guys.spr(enemy_slot))->didScriptThisFrame = true;
18962 }
18963 }
18964 2195 }
18965 2195 }
18966 2195 }
18967
18968
2/2
✓ Branch 0 taken 53704 times.
✓ Branch 1 taken 578 times.
54282 if(sle_cnt<=0)
18969 {
18970
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 578 times.
578 if (script_sle[screen])
18971 script_sle[screen] = false;
18972 else
18973 {
18974 578 get_screen_state(screen).loaded_enemies = true;
18975 }
18976 578 sle_clk = 0;
18977 578 }
18978 54516 }
18979
18980 1271103 bool is_starting_pos(mapscr* scr, int32_t i, int32_t x, int32_t y, int32_t t)
18981 {
18982
2/2
✓ Branch 0 taken 117220 times.
✓ Branch 1 taken 1153883 times.
1271103 if (!is_in_scrolling_region())
18983
2/4
✓ Branch 0 taken 1153883 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1153883 times.
1153883 if(scr->enemy[i]<1||scr->enemy[i]>=MAXGUYS) //Hackish fix for crash in Waterford.st on screen 0x65 of dmap 0 (map 1).
18984 {
18985 return false; //never 0, never OoB.
18986 }
18987 // No corner enemies
18988
6/6
✓ Branch 0 taken 1098758 times.
✓ Branch 1 taken 172345 times.
✓ Branch 2 taken 41603 times.
✓ Branch 3 taken 1140361 times.
✓ Branch 4 taken 118860 times.
✓ Branch 5 taken 95088 times.
1271103 if ((x==0 || x==world_w-16) && (y==0 || y==world_h-16))
18989 213948 return false;
18990
18991 //Is a no spawn combo...
18992
4/4
✓ Branch 0 taken 1140351 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 1140349 times.
1140361 if(MAPFLAG(x+8,y+8)==mfNOENEMYSPAWN || MAPCOMBOFLAG(x+8,y+8)==mfNOENEMYSPAWN)
18993 12 return false;
18994
18995 // No enemies in dungeon walls
18996
2/2
✓ Branch 0 taken 485260 times.
✓ Branch 1 taken 655089 times.
1140349 if (isdungeon(scr->screen))
18997 {
18998 655089 auto [offx, offy] = translate_screen_coordinates_to_world(scr->screen);
18999
17/18
✓ Branch 0 taken 655089 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 582529 times.
✓ Branch 3 taken 72560 times.
✓ Branch 4 taken 582529 times.
✓ Branch 5 taken 72560 times.
✓ Branch 6 taken 509969 times.
✓ Branch 7 taken 72560 times.
✓ Branch 8 taken 509969 times.
✓ Branch 9 taken 72560 times.
✓ Branch 10 taken 422897 times.
✓ Branch 11 taken 87072 times.
✓ Branch 12 taken 422897 times.
✓ Branch 13 taken 87072 times.
✓ Branch 14 taken 87072 times.
✓ Branch 15 taken 335825 times.
✓ Branch 16 taken 87072 times.
✓ Branch 17 taken 335825 times.
655089 if(isdungeon(scr->screen) && (x<32+offx || x>=224+offx || y<32+offy || y>=144+offy))
19000 319264 return false;
19001 335825 }
19002
19003 // Too close to hero
19004
4/4
✓ Branch 0 taken 78297 times.
✓ Branch 1 taken 742788 times.
✓ Branch 2 taken 140 times.
✓ Branch 3 taken 78157 times.
821085 if(tooclose(x,y,40) && t<11)
19005 78157 return false;
19006
19007 // Can't fly onto it?
19008
4/4
✓ Branch 0 taken 144461 times.
✓ Branch 1 taken 598467 times.
✓ Branch 2 taken 36074 times.
✓ Branch 3 taken 25255 times.
804257 if(isflier(scr->enemy[i])&&
19009
2/2
✓ Branch 0 taken 140466 times.
✓ Branch 1 taken 3995 times.
144461 (flyerblocked(x+8,y+8,spw_floater,guysbuf[scr->enemy[i]])||
19010
2/2
✓ Branch 0 taken 61329 times.
✓ Branch 1 taken 79137 times.
140466 (_walkflag(x,y+8,2)&&!get_qr(qr_WALLFLIERS))))
19011 29250 return false;
19012
19013 // Can't jump onto it?
19014 if
19015 (
19016
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 88795 times.
802477 guysbuf[scr->enemy[i]].type==eeTEK
19017
19018
2/2
✓ Branch 0 taken 88813 times.
✓ Branch 1 taken 624865 times.
713678 &&
19019 (
19020
2/2
✓ Branch 0 taken 88806 times.
✓ Branch 1 taken 7 times.
88813 COMBOTYPE(x+8,y+8)==cNOJUMPZONE||
19021
2/2
✓ Branch 0 taken 88805 times.
✓ Branch 1 taken 1 times.
88806 COMBOTYPE(x+8,y+8)==cNOENEMY||
19022
1/2
✓ Branch 0 taken 88805 times.
✗ Branch 1 not taken.
88805 ispitfall(x+8,y+8)||
19023
2/2
✓ Branch 0 taken 88799 times.
✓ Branch 1 taken 6 times.
88805 MAPFLAG(x+8,y+8)==mfNOENEMY||
19024 88799 MAPCOMBOFLAG(x+8,y+8)==mfNOENEMY
19025 )
19026 )
19027 {
19028 18 return false;
19029 }
19030
19031 // Other off-limit combos
19032
6/6
✓ Branch 0 taken 598451 times.
✓ Branch 1 taken 115209 times.
✓ Branch 2 taken 509656 times.
✓ Branch 3 taken 88795 times.
✓ Branch 4 taken 280088 times.
✓ Branch 5 taken 229568 times.
1223316 if((!isflier(scr->enemy[i])&& guysbuf[scr->enemy[i]].type!=eeTEK &&
19033
2/2
✓ Branch 0 taken 287854 times.
✓ Branch 1 taken 221802 times.
509656 (_walkflag(x,y+8,2) || groundblocked(x+8,y+8,guysbuf[scr->enemy[i]]))) &&
19034 509656 guysbuf[scr->enemy[i]].type!=eeZORA)
19035 229568 return false;
19036
19037 // Don't ever generate enemies on these combos!
19038
4/4
✓ Branch 0 taken 483786 times.
✓ Branch 1 taken 306 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 483792 times.
484092 if(COMBOTYPE(x+8,y+8)==cARMOS||COMBOTYPE(x+8,y+8)==cBSGRAVE)
19039 312 return false;
19040
19041 //BS Dodongos need at least 2 spaces.
19042
4/4
✓ Branch 0 taken 1045 times.
✓ Branch 1 taken 482747 times.
✓ Branch 2 taken 1020 times.
✓ Branch 3 taken 25 times.
483792 if ((guysbuf[scr->enemy[i]].type==eeDONGO)&&(guysbuf[scr->enemy[i]].attributes[9] == 1))
19043 {
19044
3/4
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 19 times.
25 if(((x<16) ||_walkflag(x-16,y+8, 2))&&
19045
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
6 ((x>224)||_walkflag(x+16,y+8, 2))&&
19046
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
6 ((y<16) ||_walkflag(x, y-8, 2))&&
19047 ((y>144)||_walkflag(x, y+24,2)))
19048 {
19049 return false;
19050 }
19051 19 }
19052
19053 483786 return true;
19054 1164131 }
19055
19056 168020 bool is_ceiling_pattern(int32_t i)
19057 {
19058
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 167798 times.
168020 return (i==pCEILING || i==pCEILINGR);
19059 }
19060
19061 6001 rpos_t placeenemy(mapscr* scr, int32_t i, int32_t offx, int32_t offy)
19062 {
19063 6001 std::vector<rpos_t> freeposcache;
19064
19065
2/2
✓ Branch 0 taken 66011 times.
✓ Branch 1 taken 6001 times.
72012 for(int32_t y=offy; y<offy+176; y+=16)
19066 {
19067
2/2
✓ Branch 0 taken 1056176 times.
✓ Branch 1 taken 66011 times.
1122187 for(int32_t x=offx; x<offx+256; x+=16)
19068 {
19069
3/4
✓ Branch 0 taken 1056176 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 422575 times.
✓ Branch 3 taken 633601 times.
1056176 if(is_starting_pos(scr,i,x,y,0))
19070 {
19071
2/4
✓ Branch 0 taken 422575 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 422575 times.
✗ Branch 3 not taken.
422575 freeposcache.push_back(COMBOPOS_REGION(x, y));
19072 422575 }
19073 1056176 }
19074 66011 }
19075
19076
2/2
✓ Branch 0 taken 5989 times.
✓ Branch 1 taken 12 times.
6001 if (!freeposcache.empty())
19077
1/2
✓ Branch 0 taken 5989 times.
✗ Branch 1 not taken.
5989 return freeposcache[zc_oldrand()%freeposcache.size()];
19078
19079 12 return rpos_t::None;
19080 6001 }
19081
19082 84843 void spawnEnemy(mapscr* scr, int& pos, int& clk, int offx, int offy, int& fastguys, int& i, int& guycnt, int& loadcnt)
19083 {
19084 84843 int screen = scr->screen;
19085 84843 int x = 0;
19086 84843 int y = 0;
19087 84843 bool placed=false;
19088 84843 int32_t t=-1;
19089
19090 // First: enemy combo flags
19091
2/2
✓ Branch 0 taken 844917 times.
✓ Branch 1 taken 67212 times.
912129 for(int32_t sy=0; sy<176; sy+=16)
19092 {
19093
2/2
✓ Branch 0 taken 13387597 times.
✓ Branch 1 taken 827286 times.
14214883 for(int32_t sx=0; sx<256; sx+=16)
19094 {
19095 13387597 x = offx + sx;
19096 13387597 y = offy + sy;
19097 13387597 int32_t cflag = MAPFLAG(x, y);
19098 13387597 int32_t cflag_i = MAPCOMBOFLAG(x, y);
19099
19100
2/4
✓ Branch 0 taken 13387597 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13387597 times.
✗ Branch 3 not taken.
13387597 if(((cflag==mfENEMYALL)||(cflag_i==mfENEMYALL)) && (!placed))
19101 {
19102 if(!ok2add(scr, scr->enemy[i]))
19103 {
19104 if (loadcnt < 10 && scr->enemy[i] > 0 && scr->enemy[i] < MAXGUYS) ++loadcnt;
19105 }
19106 else
19107 {
19108 addenemy_z(screen,x,
19109 (is_ceiling_pattern(scr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : y,
19110 (is_ceiling_pattern(scr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,scr->enemy[i],-15);
19111
19112 ++guycnt;
19113
19114 placed=true;
19115 goto placed_enemy;
19116 }
19117 }
19118
19119
4/4
✓ Branch 0 taken 13369917 times.
✓ Branch 1 taken 17680 times.
✓ Branch 2 taken 13369917 times.
✓ Branch 3 taken 17680 times.
13387597 else if(((cflag==mfENEMY0+i)||(cflag_i==mfENEMY0+i)) && (!placed))
19120 {
19121
2/2
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 17631 times.
17680 if(!ok2add(scr, scr->enemy[i]))
19122 {
19123
4/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 37 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
49 if (loadcnt < 10 && scr->enemy[i] > 0 && scr->enemy[i] < MAXGUYS) ++loadcnt;
19124 49 }
19125 else
19126 {
19127 35262 addenemy_z(screen,x,
19128
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 17630 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
17631 (is_ceiling_pattern(scr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : y,
19129
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 17630 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
17631 (is_ceiling_pattern(scr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,scr->enemy[i],-15);
19130
19131 17631 ++guycnt;
19132
19133 17631 placed=true;
19134 17631 goto placed_enemy;
19135 }
19136 49 }
19137 13369966 }
19138 827286 }
19139
19140 // Next: enemy pattern
19141
6/8
✓ Branch 0 taken 5098 times.
✓ Branch 1 taken 62114 times.
✓ Branch 2 taken 61478 times.
✓ Branch 3 taken 5734 times.
✓ Branch 4 taken 61478 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 61478 times.
67212 if((scr->pattern==pRANDOM || scr->pattern==pCEILING) && !(isSideViewGravity()) && ((scr->enemy[i]>0&&scr->enemy[i]<MAXGUYS)))
19142 {
19143 61478 do
19144 {
19145
19146 // NES positions
19147 108222 pos%=9;
19148 108222 x=offx+stx[loadside][pos];
19149 108222 y=offy+sty[loadside][pos];
19150 108222 ++pos;
19151 108222 ++t;
19152
2/2
✓ Branch 0 taken 46744 times.
✓ Branch 1 taken 61478 times.
169700 }
19153
2/2
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 107955 times.
108222 while((t< 20) && !is_starting_pos(scr,i,x,y,t));
19154 61478 }
19155
19156
4/4
✓ Branch 0 taken 61478 times.
✓ Branch 1 taken 5734 times.
✓ Branch 2 taken 267 times.
✓ Branch 3 taken 61211 times.
67212 if(t<0 || t >= 20) // above enemy pattern failed
19157 {
19158 // Final chance: find a random position anywhere onscreen
19159 6001 rpos_t rand_rpos = placeenemy(scr, i, offx, offy);
19160
19161
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5989 times.
6001 if (rand_rpos != rpos_t::None)
19162 {
19163 5989 std::tie(x, y) = COMBOXY_REGION(rand_rpos);
19164 5989 }
19165 else // All opportunities failed - abort
19166 {
19167 12 return;
19168 }
19169 5989 }
19170
19171 {
19172 67200 int32_t c=0;
19173 67200 c=clk;
19174
19175
2/2
✓ Branch 0 taken 10334 times.
✓ Branch 1 taken 56866 times.
67200 if(!slowguy(scr->enemy[i]))
19176 56866 ++fastguys;
19177
2/2
✓ Branch 0 taken 1768 times.
✓ Branch 1 taken 8566 times.
10334 else if(fastguys>0)
19178 1768 c=-15*(i-fastguys+2);
19179 else
19180 8566 c=-15*(i+1);
19181
19182
4/6
✓ Branch 0 taken 32607 times.
✓ Branch 1 taken 34593 times.
✓ Branch 2 taken 32607 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 32607 times.
67200 if(BSZ&&((scr->enemy[i]>0&&scr->enemy[i]<MAXGUYS))) // Hackish fix for crash in Waterford.qst on screen 0x65 of dmap 0 (map 1).
19183 {
19184 // Special case for blue leevers
19185
4/4
✓ Branch 0 taken 2364 times.
✓ Branch 1 taken 30243 times.
✓ Branch 2 taken 1189 times.
✓ Branch 3 taken 1175 times.
32607 if(guysbuf[scr->enemy[i]].type==eeLEV && guysbuf[scr->enemy[i]].attributes[0] == 1)
19186 1189 c=-15*(i+1);
19187 else
19188 31418 c=-15;
19189 32607 }
19190
19191
2/2
✓ Branch 0 taken 66379 times.
✓ Branch 1 taken 821 times.
67200 if(!ok2add(scr, scr->enemy[i]))
19192 {
19193
4/6
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 685 times.
✓ Branch 2 taken 136 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 136 times.
821 if (loadcnt < 10 && scr->enemy[i] > 0 && scr->enemy[i] < MAXGUYS) ++loadcnt;
19194 821 }
19195 else
19196 {
19197
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 66379 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
66379 if(((scr->enemy[i]>0||scr->enemy[i]<MAXGUYS))) // Hackish fix for crash in Waterford.qst on screen 0x65 of dmap 0 (map 1).
19198 {
19199
3/4
✓ Branch 0 taken 277 times.
✓ Branch 1 taken 66102 times.
✓ Branch 2 taken 277 times.
✗ Branch 3 not taken.
132758 addenemy_z(screen,x,(is_ceiling_pattern(scr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : y,
19200
3/4
✓ Branch 0 taken 277 times.
✓ Branch 1 taken 66102 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 277 times.
66379 (is_ceiling_pattern(scr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,scr->enemy[i],c);
19201
19202 66379 ++guycnt;
19203 66379 }
19204 }
19205
19206 67200 placed=true;
19207 67200 } // if(t < 20)
19208
19209 placed_enemy:
19210
19211 // I don't like this, but it seems to work...
19212 static bool foundCarrier;
19213
19214
2/2
✓ Branch 0 taken 62100 times.
✓ Branch 1 taken 22731 times.
84831 if(i==0)
19215 22731 foundCarrier=false;
19216
19217
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 84831 times.
84831 if(placed)
19218 {
19219
4/4
✓ Branch 0 taken 22731 times.
✓ Branch 1 taken 62100 times.
✓ Branch 2 taken 22550 times.
✓ Branch 3 taken 181 times.
84831 if(i==0 && scr->flags11&efLEADER)
19220 {
19221 181 enemy* e = find_guy_first_for_id(screen, scr->enemy[i], 0xFFF);
19222
2/2
✓ Branch 0 taken 174 times.
✓ Branch 1 taken 7 times.
181 if (e)
19223 {
19224 //grab the first segment. Not accurate to how older versions did it, but the way they did it might be incompatible with enemy editor.
19225
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 174 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
174 if ((e->type == eeLANM) && !get_qr(qr_NO_LANMOLA_RINGLEADER))
19226 {
19227 e = find_guy_nth_for_id(screen, scr->enemy[i], 2, 0xFFF);
19228 }
19229
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 174 times.
174 if (e)
19230 {
19231 174 e->leader = true;
19232 174 }
19233 174 }
19234 181 }
19235
19236 84831 ScreenItemState item_state = get_screen_state(screen).item_state;
19237
5/6
✓ Branch 0 taken 84587 times.
✓ Branch 1 taken 244 times.
✓ Branch 2 taken 84587 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 84 times.
✓ Branch 5 taken 84503 times.
84831 if (!foundCarrier && (item_state == ScreenItemState::CarriedByEnemy || item_state == ScreenItemState::MustGiveToEnemy))
19238 {
19239 84 enemy* e = find_guy_first_for_id(screen, scr->enemy[i], 0xFFF);
19240
2/4
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 84 times.
84 if (e && (e->flags&guy_doesnt_count)==0)
19241 {
19242 84 e->itemguy = true;
19243 84 foundCarrier=true;
19244 84 }
19245 84 }
19246 84831 }
19247 84843 }
19248
19249 // returns index of first sprite with matching id, -1 if none found
19250 265 enemy* find_guy_first_for_id(int screen, int id, int mask)
19251 {
19252 265 int count = guys.Count();
19253
2/2
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 7 times.
392 for (int32_t i=0; i<count; i++)
19254 {
19255 385 enemy* e = (enemy*)guys.spr(i);
19256
4/4
✓ Branch 0 taken 337 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 258 times.
✓ Branch 3 taken 79 times.
385 if (e->screen_spawned == screen && (e->id&mask) == (id&mask))
19257 {
19258 258 return e;
19259 }
19260 127 }
19261
19262 7 return nullptr;
19263 265 }
19264
19265 enemy* find_guy_nth_for_id(int screen, int id, int n, int mask)
19266 {
19267 int count = guys.Count();
19268 for(int32_t i=0; i<count; i++)
19269 {
19270 enemy* e = (enemy*)guys.spr(i);
19271 if (e->screen_spawned == screen && (e->id&mask) == (id&mask))
19272 {
19273 if (n > 1) --n;
19274 else return e;
19275 }
19276 }
19277 return nullptr;
19278 }
19279
19280 14 bool scriptloadenemies(int screen)
19281 {
19282 // https://discord.com/channels/876899628556091432/1395904851908755577
19283
5/14
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 14 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 14 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
28 bool replay_compat_enemies_load_bug = replay_is_active() && replay_get_meta_bool("compat_scriptloadenemies");
19284 14 auto& state = get_screen_state(screen);
19285
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if (!replay_compat_enemies_load_bug)
19286 state.loaded_enemies = true;
19287
19288
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
14 if (sle_clk || script_sle[screen]) return false;
19289
19290 14 mapscr* scr = get_scr(screen);
19291
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(scr->pattern==pNOSPAWN) return false;
19292
19293
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
14 if(scr->pattern==pSIDES || scr->pattern==pSIDESR)
19294 {
19295 script_side_load_enemies(scr);
19296 return true;
19297 }
19298
19299 184 auto [x, y] = translate_screen_coordinates_to_world(screen);
19300 14 int32_t pos=zc_oldrand()%9;
19301 14 int32_t clk=-15,fastguys=0;
19302 14 int32_t i=0,guycnt=0;
19303 14 int32_t loadcnt = 10;
19304
19305
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
✓ Branch 2 taken 85 times.
✓ Branch 3 taken 14 times.
99 for(; i<loadcnt && scr->enemy[i]>0; i++)
19306 {
19307 85 int32_t preguycount = guys.Count(); //I'm not experienced enough to know if this is an awful hack but it feels like one.
19308 255 spawnEnemy(scr, pos, clk, x, y, fastguys, i, guycnt, loadcnt);
19309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (guys.Count() > preguycount)
19310 {
19311
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19312 {
19313
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19314 {
19315 85 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19316 85 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19317 85 }
19318 85 }
19319 85 }
19320 85 --clk;
19321 85 }
19322 14 return true;
19323 14 }
19324
19325 14793670 void loadenemies()
19326 {
19327 29967498 for_every_base_screen_in_region([&](mapscr* scr, unsigned int region_scr_x, unsigned int region_scr_y) {
19328 15173828 int screen = scr->screen;
19329 15173828 auto& state = get_screen_state(screen);
19330
2/2
✓ Branch 0 taken 14756966 times.
✓ Branch 1 taken 416862 times.
15173828 if (state.loaded_enemies)
19331 14756966 return;
19332
19333
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 416862 times.
416862 if(getmapflag(scr, mNO_ENEMIES_RETURN))
19334 {
19335 state.loaded_enemies = true;
19336 return;
19337 }
19338
19339 // dungeon basements
19340 static byte dngn_enemy_x[4] = {32,96,144,208};
19341
2/2
✓ Branch 0 taken 148964 times.
✓ Branch 1 taken 267898 times.
416862 if (cur_screen>=128)
19342 {
19343
2/2
✓ Branch 0 taken 148489 times.
✓ Branch 1 taken 475 times.
148964 if(DMaps[cur_dmap].flags&dmfCAVES) return;
19344
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 475 times.
475 if ( DMaps[cur_dmap].flags&dmfNEWCELLARENEMIES )
19345 {
19346 for(int32_t i=0; i<10; i++)
19347 {
19348 if ( scr->enemy[i] )
19349 {
19350 int32_t preguycount = guys.Count();
19351 addenemy(screen,dngn_enemy_x[i],96,scr->enemy[i],-14-i);
19352 if (guys.Count() > preguycount)
19353 {
19354 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19355 {
19356 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19357 {
19358 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19359 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19360 }
19361 }
19362 }
19363 }
19364 }
19365 }
19366 else
19367 {
19368
2/2
✓ Branch 0 taken 1900 times.
✓ Branch 1 taken 475 times.
2375 for(int32_t i=0; i<4; i++)
19369 {
19370 1900 int32_t preguycount = guys.Count();
19371
2/2
✓ Branch 0 taken 1044 times.
✓ Branch 1 taken 856 times.
1900 addenemy(screen,dngn_enemy_x[i],96,scr->enemy[i]?scr->enemy[i]:(int32_t)eKEESE1,-14-i);
19372
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1900 times.
1900 if (guys.Count() > preguycount)
19373 {
19374
2/2
✓ Branch 0 taken 1896 times.
✓ Branch 1 taken 4 times.
1900 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19375 {
19376
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19377 {
19378 4 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19379 4 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19380 4 }
19381 4 }
19382 1900 }
19383 1900 }
19384 }
19385
19386 475 state.loaded_enemies = true;
19387 475 return;
19388 }
19389
19390
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 267898 times.
267898 if (scr->pattern == pNOSPAWN)
19391 return;
19392
19393 // TODO: configure when screen enemies spawn.
19394
2/2
✓ Branch 0 taken 90606 times.
✓ Branch 1 taken 177292 times.
267898 if (!viewport.intersects_with(region_scr_x*256, region_scr_y*176, 256, 176))
19395 177292 return;
19396
19397
4/4
✓ Branch 0 taken 52159 times.
✓ Branch 1 taken 38447 times.
✓ Branch 2 taken 16069 times.
✓ Branch 3 taken 36090 times.
90606 if (scr->pattern==pSIDES || scr->pattern==pSIDESR)
19398 {
19399 54516 side_load_enemies(scr);
19400 54516 return;
19401 }
19402
19403 36090 state.loaded_enemies = true;
19404
19405 // check if it's the dungeon boss and it has been beaten before
19406
4/4
✓ Branch 0 taken 378 times.
✓ Branch 1 taken 35712 times.
✓ Branch 2 taken 283 times.
✓ Branch 3 taken 95 times.
36090 if (scr->flags11&efBOSS && game->lvlitems[dlevel]&(1 << li_boss_killed))
19407 95 return;
19408
19409 35995 int32_t loadcnt = 10;
19410 35995 int16_t mi = mapind(cur_map, screen);
19411 35995 bool beenhere = check_if_recently_visited();
19412
19413 //Okay so this basically checks the last 6 unique screen's you've been in and checks if the current screen is one of them.
19414 35995 bool reload = true;
19415
4/4
✓ Branch 0 taken 10302 times.
✓ Branch 1 taken 25693 times.
✓ Branch 2 taken 5031 times.
✓ Branch 3 taken 5271 times.
35995 if (beenhere && game->guys[mi] == 0) //Then, if you have been here, and the number of enemies left on the screen is 0,
19416 {
19417 5271 loadcnt = 0; //It will tell it not to load any enemies,
19418 5271 reload = false; //both by setting loadcnt to 0 and making the reload if statement not run.
19419 5271 }
19420
19421 35995 bool unbeatablereload = true;
19422
2/2
✓ Branch 0 taken 5271 times.
✓ Branch 1 taken 30724 times.
35995 if(reload) //This if statement is only false if this screen is one of the last 6 screens you visited and you left 0 enemies alive.
19423 {
19424 30724 loadcnt = game->guys[mi]; //Otherwise, if this if statement is true, it will try to load the last amount of enemies you left alive.
19425
19426
2/4
✓ Branch 0 taken 11007 times.
✓ Branch 1 taken 19717 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30724 if(loadcnt==0 || //Then, if the number of enemies is 0, that means you left 0 enemies alive on a screen but haven't been there in the past 6 screens.
19427
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11007 times.
11007 (get_qr(qr_NO_LEAVE_ONE_ENEMY_ALIVE_TRICK) && !beenhere)) //Alternatively, if you have the quest rule enabled that always respawns all enemies after a period of time, and you haven't been here in 6 screens.
19428 19717 loadcnt = 10; //That means all enemies need to be respawned.
19429
3/4
✓ Branch 0 taken 25693 times.
✓ Branch 1 taken 5031 times.
✓ Branch 2 taken 25693 times.
✗ Branch 3 not taken.
30724 if (!beenhere && get_qr(qr_UNBEATABLES_DONT_KEEP_DEAD))
19430 {
19431 for(int32_t i = 0; i<loadcnt && scr->enemy[i]>0; i++)
19432 {
19433 if (!(guysbuf[scr->enemy[i]].flags & guy_doesnt_count))
19434 {
19435 unbeatablereload = false;
19436 }
19437 }
19438 if (unbeatablereload)
19439 {
19440 loadcnt = 10;
19441 }
19442 }
19443 30724 }
19444
19445
4/4
✓ Branch 0 taken 34534 times.
✓ Branch 1 taken 1461 times.
✓ Branch 2 taken 212 times.
✓ Branch 3 taken 34322 times.
35995 if((get_qr(qr_ALWAYSRET)) || (scr->flags3&fENEMIESRETURN)) //If enemies always return is enabled quest-wide or for this screen,
19446 1673 loadcnt = 10; //All enemies also need to be respawned.
19447
19448 // do enemies that are always loaded
19449 35995 load_default_enemies(scr);
19450 35995 activate_fireball_statues(scr);
19451
19452 35995 int32_t pos=zc_oldrand()%9; //This sets up a variable for spawnEnemy to edit so as to spawn the enemies pseudo-randomly.
19453 35995 int32_t clk=-15,fastguys=0; //clk being negative means the enemy is in it's spawn poof.
19454 35995 int32_t i=0,guycnt=0; //Lastly, resets guycnt to 0 so spawnEnemy can increment it manually per-enemy.
19455
4/4
✓ Branch 0 taken 16124 times.
✓ Branch 1 taken 104629 times.
✓ Branch 2 taken 84758 times.
✓ Branch 3 taken 35995 times.
120753 for(; i<loadcnt && scr->enemy[i]>0; i++)
19456 {
19457 84758 int32_t preguycount = guys.Count(); //I'm not experienced enough to know if this is an awful hack but it feels like one.
19458 84758 spawnEnemy(scr, pos, clk, region_scr_x*256, region_scr_y*176, fastguys, i, guycnt, loadcnt);
19459
2/2
✓ Branch 0 taken 833 times.
✓ Branch 1 taken 83925 times.
84758 if (guys.Count() > preguycount)
19460 {
19461
2/2
✓ Branch 0 taken 77968 times.
✓ Branch 1 taken 5957 times.
83925 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19462 {
19463
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 5953 times.
5957 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19464 {
19465 5953 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19466 5953 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19467 5953 }
19468 5957 }
19469 83925 }
19470
19471 84758 --clk; //Each additional enemy spawns with a slightly longer spawn poof than the previous.
19472 84758 }
19473
19474 35995 game->guys[mi] = guycnt;
19475 15173828 });
19476 14793670 }
19477
19478 233 void moneysign()
19479 {
19480 466 auto [dx, dy] = translate_screen_coordinates_to_world(cur_screen);
19481 466 additem(dx+48,dy+108,iRupy,ipDUMMY);
19482 233 set_clip_state(pricesdisplaybuf, 0);
19483 233 textout_ex(pricesdisplaybuf,get_zc_font(font_zfont),"X",64,112,CSET(0)+1,-1);
19484 233 }
19485
19486 3414 void putprices(bool sign)
19487 {
19488
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 3382 times.
3414 if(fadeclk > 0) return;
19489
19490 3382 rectfill(pricesdisplaybuf, 72, 112, pricesdisplaybuf->w-1, pricesdisplaybuf->h-1, 0);
19491 3382 int32_t step=32;
19492 3382 int32_t x=80;
19493
19494
2/2
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 3101 times.
3382 if(prices[2]==0)
19495 {
19496 3101 step<<=1;
19497
19498
2/2
✓ Branch 0 taken 3069 times.
✓ Branch 1 taken 32 times.
3101 if(prices[1]==0)
19499 {
19500 3069 x=112;
19501 3069 }
19502 3101 }
19503
19504
2/2
✓ Branch 0 taken 3382 times.
✓ Branch 1 taken 10146 times.
13528 for(int32_t i=0; i<3; i++)
19505 {
19506 // Kind of stupid, but it works: 100000 is used to indicate that an item
19507 // has a price of zero rather than there being no item.
19508 // 100000 isn't a valid price, so this doesn't cause problems.
19509
3/4
✓ Branch 0 taken 1039 times.
✓ Branch 1 taken 9107 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1039 times.
10146 if(prices[i]!=0 && prices[i]<100000)
19510 {
19511 char buf[8];
19512 1039 sprintf(buf,sign?"%+3d":"%3d",prices[i]);
19513
19514 1039 int32_t l=(int32_t)strlen(buf);
19515 1039 set_clip_state(pricesdisplaybuf, 0);
19516
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 1012 times.
1039 textout_ex(pricesdisplaybuf,get_zc_font(font_zfont),buf,x-(l>3?(l-3)<<3:0),112,CSET(0)+1,-1);
19517 1039 }
19518
19519 10146 x+=step;
19520 10146 }
19521 3414 }
19522
19523 // Setting up special rooms
19524 // Also called when the Letter is used successfully.
19525 1217 void setupscreen()
19526 {
19527 1217 boughtsomething=false;
19528
19529 // Either the origin screen, or if in a 0x80 room the screen player came from.
19530
2/2
✓ Branch 0 taken 416 times.
✓ Branch 1 taken 801 times.
1217 mapscr* base_scr = cur_screen >= 128 ? special_warp_return_scr : origin_scr;
19531 1217 mapscr* scr = origin_scr;
19532
19533 1217 word str=base_scr->str;
19534
19535 2269 auto [dx, dy] = translate_screen_coordinates_to_world(scr->screen);
19536
19537 // Prices are already set to 0 in dowarp()
19538
14/15
✓ Branch 0 taken 174 times.
✓ Branch 1 taken 696 times.
✓ Branch 2 taken 164 times.
✓ Branch 3 taken 28 times.
✓ Branch 4 taken 44 times.
✓ Branch 5 taken 11 times.
✓ Branch 6 taken 13 times.
✓ Branch 7 taken 2 times.
✓ Branch 8 taken 2 times.
✓ Branch 9 taken 17 times.
✓ Branch 10 taken 32 times.
✓ Branch 11 taken 1 times.
✓ Branch 12 taken 19 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 14 times.
1217 switch(base_scr->room)
19539 {
19540 case rSP_ITEM: // special item
19541 328 additem(dx+120,dy+89,base_scr->catchall,ipONETIME2+ipHOLDUP+ipCHECK | ((scr->flags8&fITEMSECRET) ? ipSECRETS : 0));
19542 164 break;
19543
19544 case rINFO: // pay for info
19545 {
19546 28 int32_t count = 0;
19547 28 int32_t base = 88;
19548 28 int32_t step = 5;
19549
19550 28 moneysign();
19551
19552
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 84 times.
112 for(int32_t i=0; i<3; i++)
19553 {
19554
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 if(QMisc.info[base_scr->catchall].str[i])
19555 {
19556 84 ++count;
19557 84 }
19558 else
19559 break;
19560 84 }
19561
19562
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
28 if(count)
19563 {
19564
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(count==1)
19565 {
19566 base = 88+32;
19567 }
19568
19569
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(count==2)
19570 {
19571 step = 6;
19572 }
19573
19574
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 28 times.
112 for(int32_t i=0; i < count; i++)
19575 {
19576 84 additem((i << step)+base, 89, iRupy, ipMONEY + ipDUMMY);
19577 84 ((item*)items.spr(items.Count()-1))->PriceIndex = i;
19578 84 prices[i] = -(QMisc.info[base_scr->catchall].price[i]);
19579
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 if(prices[i]==0)
19580 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
19581 84 int32_t itemid = current_item_id(itype_wealthmedal);
19582
19583
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
84 if(itemid>=0 && prices[i]!=100000)
19584 {
19585 if(itemsbuf[itemid].flags & item_flag1)
19586 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
19587 else
19588 prices[i]-=itemsbuf[itemid].misc1;
19589 prices[i]=vbound(prices[i], -99999, 0);
19590 if(prices[i]==0)
19591 prices[i]=100000;
19592 }
19593
19594
2/6
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 84 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
84 if((QMisc.info[base_scr->catchall].price[i])>1 && prices[i]>-1 && prices[i]!=100000)
19595 prices[i]=-1;
19596 84 }
19597 28 }
19598
19599 28 break;
19600 }
19601
19602 case rMONEY: // secret money
19603 88 additem(dx+120,dy+89,iRupy,ipONETIME+ipDUMMY+ipMONEY);
19604 44 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19605 44 break;
19606
19607 case rGAMBLE: // gambling
19608 11 prices[0]=prices[1]=prices[2]=-10;
19609 11 moneysign();
19610 22 additem(dx+88,dy+89,iRupy,ipMONEY+ipDUMMY);
19611 11 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19612 22 additem(dx+120,dy+89,iRupy,ipMONEY+ipDUMMY);
19613 11 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
19614 22 additem(dx+152,dy+89,iRupy,ipMONEY+ipDUMMY);
19615 11 ((item*)items.spr(items.Count()-1))->PriceIndex = 2;
19616 11 break;
19617
19618 case rREPAIR: // door repair
19619
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 setmapflag(scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
19620 // }
19621 13 repaircharge=base_scr->catchall;
19622 13 break;
19623
19624 case rMUPGRADE: // upgrade magic
19625 2 adjustmagic=true;
19626 2 break;
19627
19628 case rLEARNSLASH: // learn slash attack
19629 2 learnslash=true;
19630 2 break;
19631
19632 case rRP_HC: // heart container or red potion
19633 34 additem(dx+88,dy+89,iRPotion,ipONETIME2+ipHOLDUP+ipFADE);
19634 17 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19635 34 additem(dx+152,dy+89,iHeartC,ipONETIME2+ipHOLDUP+ipFADE);
19636 17 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
19637 17 break;
19638
19639 case rP_SHOP: // potion shop
19640
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 20 times.
32 if(current_item(itype_letter)<i_letter_used)
19641 {
19642 12 str=0;
19643 12 break;
19644 }
19645
19646 [[fallthrough]];
19647 case rTAKEONE: // take one
19648 case rSHOP: // shop
19649 {
19650 194 int32_t count = 0;
19651 194 int32_t base = 88;
19652 194 int32_t step = 5;
19653
19654
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 193 times.
194 if(base_scr->room != rTAKEONE)
19655 193 moneysign();
19656
19657 //count and align the stuff
19658
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 560 times.
717 for(int32_t i=0; i<3; ++i)
19659 {
19660
2/2
✓ Branch 0 taken 523 times.
✓ Branch 1 taken 37 times.
560 if(QMisc.shop[base_scr->catchall].hasitem[count] != 0)
19661 {
19662 523 ++count;
19663 523 }
19664 else
19665 {
19666 37 break;
19667 }
19668 523 }
19669
19670
2/2
✓ Branch 0 taken 172 times.
✓ Branch 1 taken 22 times.
194 if(count==1)
19671 {
19672 22 base = 88+32;
19673 22 }
19674
19675
2/2
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 15 times.
194 if(count==2)
19676 {
19677 15 step = 6;
19678 15 }
19679
19680
2/2
✓ Branch 0 taken 523 times.
✓ Branch 1 taken 194 times.
717 for(int32_t i=0; i<count; i++)
19681 {
19682 1046 additem(dx+(i<<step)+base, dy+89, QMisc.shop[base_scr->catchall].item[i], ipHOLDUP+ipFADE+(base_scr->room == rTAKEONE ? ipONETIME2 : ipCHECK));
19683 523 ((item*)items.spr(items.Count()-1))->PriceIndex = i;
19684
19685
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 521 times.
523 if(base_scr->room != rTAKEONE)
19686 {
19687 521 prices[i] = QMisc.shop[base_scr->catchall].price[i];
19688
1/2
✓ Branch 0 taken 521 times.
✗ Branch 1 not taken.
521 if(prices[i]==0)
19689 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
19690 521 int32_t itemid = current_item_id(itype_wealthmedal);
19691
19692
3/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 512 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
521 if(itemid>=0 && prices[i]!=100000)
19693 {
19694
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(itemsbuf[itemid].flags & item_flag1)
19695 9 prices[i]=((prices[i]*itemsbuf[itemid].misc1) / 100);
19696 else
19697 prices[i]+=itemsbuf[itemid].misc1;
19698 9 prices[i]=vbound(prices[i], 0, 99999);
19699
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(prices[i]==0)
19700 prices[i]=100000;
19701 9 }
19702
19703
2/4
✓ Branch 0 taken 521 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 521 times.
✗ Branch 3 not taken.
521 if((QMisc.shop[base_scr->catchall].price[i])>1 && prices[i]<1)
19704 prices[i]=1;
19705 521 }
19706 523 }
19707
19708 194 break;
19709 }
19710 case rBOTTLESHOP: // bottle shop
19711 {
19712 1 int32_t count = 0;
19713 1 int32_t base = 88;
19714 1 int32_t step = 5;
19715
19716 1 moneysign();
19717 1 bottleshoptype const& bst = QMisc.bottle_shop_types[base_scr->catchall];
19718 //count and align the stuff
19719
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3 times.
4 for(int32_t i=0; i<3; ++i)
19720 {
19721
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(bst.fill[count] != 0)
19722 {
19723 3 ++count;
19724 3 }
19725 else
19726 {
19727 break;
19728 }
19729 3 }
19730
19731
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(count==1)
19732 {
19733 base = 88+32;
19734 }
19735
19736
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(count==2)
19737 {
19738 step = 6;
19739 }
19740
19741
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
4 for(int32_t i=0; i<count; i++)
19742 {
19743 6 adddummyitem(dx+(i<<step)+base, dy+89, /*Use item 0 as a dummy...*/0, ipHOLDUP+ipFADE+ipCHECK);
19744 //{ Setup dummy item
19745 3 item* curItem = ((item*)items.spr(items.Count()-1));
19746 3 curItem->PriceIndex = i;
19747 3 newcombo const& cmb = combobuf[bst.comb[i]];
19748
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(cmb.animflags & AF_EDITOR_ONLY)
19749 {
19750 curItem->yofs = -32768;
19751 }
19752 3 curItem->o_tile = cmb.o_tile;
19753 3 curItem->o_cset = bst.cset[i];
19754 3 curItem->cs = curItem->o_cset;
19755 3 curItem->tile = cmb.o_tile;
19756 3 curItem->o_speed = cmb.speed;
19757 3 curItem->o_delay = 0;
19758 3 curItem->frames = cmb.frames;
19759 3 curItem->flip = cmb.flip;
19760 3 curItem->type = itype_bottlefill; //no pickup w/o empty bottle
19761 3 curItem->pstring = 0;
19762 3 curItem->pickup = ipHOLDUP+ipFADE+ipCHECK;
19763 3 curItem->flash = false;
19764 3 curItem->twohand = false;
19765 3 curItem->anim = true;
19766 3 curItem->hit_width=1;
19767 3 curItem->hyofs=4;
19768 3 curItem->hit_height=12;
19769 3 curItem->script=0;
19770 3 curItem->txsz=1;
19771 3 curItem->tysz=1;
19772 //}
19773
19774 3 prices[i] = bst.price[i];
19775
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(prices[i]==0)
19776 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
19777 3 int32_t itemid = current_item_id(itype_wealthmedal);
19778
19779
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if(itemid>=0 && prices[i]!=100000)
19780 {
19781 if(itemsbuf[itemid].flags & item_flag1)
19782 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
19783 else
19784 prices[i]+=itemsbuf[itemid].misc1;
19785 prices[i]=vbound(prices[i], 0, 99999);
19786 if(prices[i]==0)
19787 prices[i]=100000;
19788 }
19789
19790
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if((bst.price[i])>1 && prices[i]<1)
19791 prices[i]=1;
19792 3 }
19793
19794 1 break;
19795 }
19796
19797 case rBOMBS: // more bombs
19798 38 additem(dx+120,dy+89,iRupy,ipDUMMY+ipMONEY);
19799 19 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19800 19 prices[0]=-base_scr->catchall;
19801 19 break;
19802
19803 case rARROWS: // more arrows
19804 additem(dx+120,dy+89,iRupy,ipDUMMY+ipMONEY);
19805 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19806 prices[0]=-base_scr->catchall;
19807 break;
19808
19809 case rSWINDLE: // leave heart container or money
19810 28 additem(dx+88,dy+89,iHeartC,ipDUMMY+ipMONEY);
19811 14 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19812 14 prices[0]=-1;
19813 28 additem(dx+152,dy+89,iRupy,ipDUMMY+ipMONEY);
19814 14 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
19815 14 prices[1]=-base_scr->catchall;
19816 14 break;
19817
19818 }
19819
19820
3/4
✓ Branch 0 taken 1198 times.
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1198 times.
1217 if(base_scr->room == rBOMBS || base_scr->room == rARROWS)
19821 {
19822 19 int32_t i = (base_scr->room == rSWINDLE ? 1 : 0);
19823 19 int32_t itemid = current_item_id(itype_wealthmedal);
19824
19825
1/2
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
19 if(itemid >= 0)
19826 {
19827 if(itemsbuf[itemid].flags & item_flag1)
19828 prices[i]*=(itemsbuf[itemid].misc1 /100.0);
19829 else
19830 prices[i]+=itemsbuf[itemid].misc1;
19831 }
19832
19833
2/4
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19 times.
✗ Branch 3 not taken.
19 if(base_scr->catchall>1 && prices[i]>-1)
19834 prices[i]=-1;
19835 19 }
19836
19837 1217 putprices(false);
19838
19839
2/2
✓ Branch 0 taken 1158 times.
✓ Branch 1 taken 59 times.
1217 if(str)
19840 {
19841 1158 donewmsg(base_scr, str);
19842 1158 }
19843 else
19844 {
19845 59 Hero.unfreeze();
19846 }
19847 1217 }
19848
19849 enum
19850 {
19851 MNU_CURSOR_TILE, MNU_CURSOR_CSET,
19852 MNU_CURSOR_WID, MNU_CURSOR_HEI, MNU_CURSOR_FLIP,
19853
19854 MNU_CHOSEN, MNU_TIMER, MNU_CAN_CONFIRM,
19855
19856 MNU_DATA_MAX
19857 };
19858 struct menu_choice
19859 {
19860 int32_t x, y;
19861 int32_t pos;
19862 int32_t upos, dpos, lpos, rpos;
19863 18 menu_choice() : x(0), y(0), pos(0), upos(0), dpos(0), lpos(0), rpos(0)
19864 18 {}
19865 18 menu_choice(int32_t x, int32_t y, int32_t pos, int32_t upos,
19866 int32_t dpos, int32_t lpos, int32_t rpos)
19867 18 : x(x), y(y), pos(pos), upos(upos), dpos(dpos), lpos(lpos), rpos(rpos)
19868 18 {}
19869 };
19870 static int32_t msg_menu_data[MNU_DATA_MAX];
19871 static bool do_run_menu = false;
19872 bool do_end_str = false;
19873 static bool wait_advance = false;
19874 427 static std::map<int32_t, menu_choice> menu_options;
19875 46339 void clr_msg_data()
19876 {
19877 46339 do_end_str = false;
19878 46339 wait_advance = false;
19879 46339 do_run_menu = false;
19880 46339 menu_options.clear();
19881 46339 memset(msg_menu_data, 0, sizeof(msg_menu_data));
19882 46339 }
19883
19884 static char namebuf[9] = {0};
19885 static char* nameptr = NULL;
19886 static int32_t ssc_tile_hei = -1, ssc_tile_hei_buf = -1;
19887 2050 bool runMenuCursor()
19888 {
19889 2050 clear_bitmap(msg_menu_bmp_buf);
19890
1/2
✓ Branch 0 taken 2050 times.
✗ Branch 1 not taken.
2050 if(!menu_options.size())
19891 {
19892 msg_menu_data[MNU_CHOSEN] = 0;
19893 return true; //end menu
19894 }
19895 2050 int32_t pos = msg_menu_data[MNU_CHOSEN];
19896 //If the cursor is at an invalid pos, find the first pos >= 0...
19897
1/2
✓ Branch 0 taken 2050 times.
✗ Branch 1 not taken.
2050 if(menu_options.find(pos) == menu_options.end())
19898 {
19899 pos = 0;
19900 while(menu_options.find(pos) == menu_options.end())
19901 ++pos;
19902 }
19903 2050 menu_choice* ch = &menu_options[pos];
19904
19905 2050 bool pressed = true;
19906
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2046 times.
2050 if(rUp()) pos = ch->upos;
19907
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2044 times.
2046 else if(rDown()) pos = ch->dpos;
19908
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2035 times.
2044 else if(rLeft()) pos = ch->lpos;
19909
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 2024 times.
2035 else if(rRight()) pos = ch->rpos;
19910 2024 else pressed = false;
19911
19912
2/2
✓ Branch 0 taken 2024 times.
✓ Branch 1 taken 26 times.
2050 if(pressed)
19913 26 msg_menu_data[MNU_TIMER] = 1;
19914
19915 2050 bool hold_input = !((msg_menu_data[MNU_TIMER]++) % 20);
19916 2050 bool held = false;
19917
2/2
✓ Branch 0 taken 1959 times.
✓ Branch 1 taken 91 times.
2050 if(hold_input)
19918 {
19919 91 held = true;
19920
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 90 times.
91 if(Up()) pos = ch->upos;
19921
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 90 times.
90 else if(Down()) pos = ch->dpos;
19922
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 90 times.
90 else if(Left()) pos = ch->lpos;
19923
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 90 times.
90 else if(Right()) pos = ch->rpos;
19924 90 else held = false;
19925 91 }
19926 //If the cursor is at an invalid pos, find the first pos >= 0...
19927
1/2
✓ Branch 0 taken 2050 times.
✗ Branch 1 not taken.
2050 if(menu_options.find(pos) == menu_options.end())
19928 {
19929 pos = 0;
19930 while(menu_options.find(pos) == menu_options.end())
19931 ++pos;
19932 }
19933
4/4
✓ Branch 0 taken 2024 times.
✓ Branch 1 taken 26 times.
✓ Branch 2 taken 2023 times.
✓ Branch 3 taken 27 times.
2050 if((pressed || held) && pos != msg_menu_data[MNU_CHOSEN])
19934 27 sfx(MsgStrings[msgstr].sfx);
19935
19936 2050 ch = &menu_options[pos];
19937 4100 overtileblock16(msg_menu_bmp_buf, msg_menu_data[MNU_CURSOR_TILE],
19938 2050 ch->x, ch->y, (int32_t)ceil(msg_menu_data[MNU_CURSOR_WID]/16.0),
19939 2050 (int32_t)ceil(msg_menu_data[MNU_CURSOR_HEI]/16.0),
19940 2050 msg_menu_data[MNU_CURSOR_CSET], msg_menu_data[MNU_CURSOR_FLIP]);
19941
19942 2050 msg_menu_data[MNU_CHOSEN] = pos;
19943
19944
2/2
✓ Branch 0 taken 1443 times.
✓ Branch 1 taken 607 times.
2050 if(!msg_menu_data[MNU_CAN_CONFIRM]) //Prevent instantly accepting when holding A
19945 {
19946 607 rAbtn(); //Eat
19947
2/2
✓ Branch 0 taken 602 times.
✓ Branch 1 taken 5 times.
607 if(!cAbtn()) msg_menu_data[MNU_CAN_CONFIRM] = 1;
19948 607 }
19949
19950
4/4
✓ Branch 0 taken 2024 times.
✓ Branch 1 taken 26 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 2023 times.
2050 bool ret = (pressed || held) ? false : rAbtn();
19951 //Eat inputs
19952 2050 rUp(); rDown(); rLeft(); rRight(); rAbtn();
19953
19954
2/2
✓ Branch 0 taken 2045 times.
✓ Branch 1 taken 5 times.
2050 if(ret)
19955 5 menu_options.clear();
19956
19957 2050 return ret;
19958 //false if pos changed this frame; no confirming while moving the cursor!
19959 2050 }
19960
19961 922981 bool bottom_margin_clip()
19962 {
19963 1057805 return !get_qr(qr_OLD_STRING_EDITOR_MARGINS)
19964
2/2
✓ Branch 0 taken 788157 times.
✓ Branch 1 taken 134824 times.
922981 && cursor_y >= (msg_h + (get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)?16:0) - msg_margins[down]);
19965 }
19966
19967 void update_msgstr();
19968
19969 3729 static bool parsemsgcode(const StringCommand& command)
19970 {
19971 3729 auto& args = command.args;
19972 3729 int last_arg = 0;
19973
19974
20/56
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1280 times.
✓ Branch 4 taken 2066 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 62 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 5 times.
✓ Branch 10 taken 7 times.
✓ Branch 11 taken 70 times.
✓ Branch 12 taken 6 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 11 times.
✓ Branch 16 taken 22 times.
✓ Branch 17 taken 7 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 1 times.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✓ Branch 35 taken 122 times.
✓ Branch 36 taken 28 times.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✓ Branch 43 taken 5 times.
✓ Branch 44 taken 18 times.
✓ Branch 45 taken 5 times.
✓ Branch 46 taken 7 times.
✗ Branch 47 not taken.
✓ Branch 48 taken 3 times.
✗ Branch 49 not taken.
✗ Branch 50 not taken.
✗ Branch 51 not taken.
✗ Branch 52 not taken.
✗ Branch 53 not taken.
✗ Branch 54 not taken.
✗ Branch 55 not taken.
3729 switch (command.code)
19975 {
19976 case MSGC_NEWLINE:
19977 {
19978 1280 ssc_tile_hei = ssc_tile_hei_buf;
19979
2/2
✓ Branch 0 taken 1278 times.
✓ Branch 1 taken 2 times.
1280 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
19980 1280 ssc_tile_hei_buf = -1;
19981 1280 cursor_y += thei + MsgStrings[msgstr].vspace;
19982 1280 cursor_x=msg_margins[left];
19983 1280 return true;
19984 }
19985
19986 case MSGC_COLOUR:
19987 {
19988 2066 int32_t cset = args[0];
19989 2066 msgcolour = CSET(cset)+(args[1]);
19990 2066 return true;
19991 }
19992
19993 case MSGC_SHDCOLOR:
19994 {
19995 int32_t cset = args[0];
19996 msg_shdcol = CSET(cset)+args[1];
19997 return true;
19998 }
19999 case MSGC_SHDTYPE:
20000 {
20001 msg_shdtype = args[0];
20002 return true;
20003 }
20004
20005 case MSGC_SPEED:
20006 {
20007 62 msgspeed=args[0];
20008 62 return true;
20009 }
20010
20011 case MSGC_CTRUP:
20012 {
20013 int32_t a1 = args[0];
20014 int32_t a2 = args[1];
20015 game->change_counter(a2, a1);
20016 return true;
20017 }
20018
20019 case MSGC_CTRDN:
20020 {
20021 5 int32_t a1 = args[0];
20022 5 int32_t a2 = args[1];
20023 5 game->change_counter(-a2, a1);
20024 5 return true;
20025 }
20026
20027 case MSGC_CTRSET:
20028 {
20029 7 int32_t a1 = args[0];
20030 7 int32_t a2 = args[1];
20031 7 game->set_counter(vbound(a2, 0, game->get_maxcounter(a1)), a1);
20032 7 return true;
20033 }
20034
20035 case MSGC_CTRUPPC:
20036 case MSGC_CTRDNPC:
20037 case MSGC_CTRSETPC:
20038 {
20039 2 int32_t counter = args[0];
20040 2 int32_t amount = args[1];
20041 2 amount = int32_t(vbound(amount*0.01, 0.0, 1.0)*game->get_maxcounter(counter));
20042
20043
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(command.code==MSGC_CTRDNPC)
20044 amount*=-1;
20045
20046
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(command.code==MSGC_CTRSETPC)
20047 game->set_counter(amount, counter);
20048 else
20049 2 game->change_counter(amount, counter);
20050
20051 2 return true;
20052 }
20053
20054 case MSGC_GIVEITEM:
20055 {
20056 70 int32_t itemID = args[0];
20057
20058 70 getitem(itemID, true);
20059
2/4
✓ Branch 0 taken 70 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 70 times.
70 if ( !FFCore.doscript(ScriptType::Item, itemID) && (((unsigned)itemID) < 256) )
20060 {
20061 70 FFCore.reset_script_engine_data(ScriptType::Item, itemID);
20062 70 FFCore.doscript(ScriptType::Item, itemID) = (itemsbuf[itemID].flags&item_passive_script) > 0;
20063 70 }
20064 70 return true;
20065 }
20066
20067 case MSGC_COLLECTITEM:
20068 {
20069 6 int32_t itemID = args[0];
20070
20071
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if (!items.has_space())
20072 {
20073 Z_error("SCC: No room to spawn item\n");
20074 return true;
20075 }
20076
20077 6 additem(0, (get_qr(qr_NOITEMOFFSET) ? 1: 0), itemID, ipHOLDUP);
20078 6 auto* s = (item*)items.spr(items.Count() - 1);
20079 6 s->screen_spawned = msgscr->screen;
20080 6 s->set_forcegrab(true);
20081 // The item will be collected by Hero::checkItems when the message box closes. However,
20082 // if qr_MSGFREEZE is off, this command will instantly close the message box. It's
20083 // expected that new quests have that QR on.
20084 6 return true;
20085 }
20086
20087 case MSGC_WARP:
20088 {
20089 int32_t dmap = args[0];
20090 int32_t scrn = args[1];
20091 int32_t dx = args[2];
20092 int32_t dy = args[3];
20093 int32_t wfx = args[4];
20094 int32_t sfx = args[5];
20095 FFCore.warp_player(wtIWARP, dmap, scrn, dx, dy, wfx, sfx, 0, 0);
20096 do_end_str = true;
20097 return true;
20098 }
20099
20100 case MSGC_SETSCREEND:
20101 {
20102 int32_t dmap = (args[0]<<7); //dmap and screen may be transposed here.
20103 int32_t screen = args[1];
20104 int32_t reg = args[2];
20105 int32_t val = args[3];
20106 FFCore.set_screen_d(screen + dmap, reg, val);
20107 return true;
20108 }
20109 case MSGC_TAKEITEM:
20110 {
20111 11 int32_t itemID = args[0];
20112
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if ( FFCore.doscript(ScriptType::Item, itemID) )
20113 {
20114 FFCore.doscript(ScriptType::Item, itemID) = 4; //Val of 4 means 'clear stack and quit'
20115 }
20116 11 takeitem(itemID);
20117
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if ( game->forced_bwpn == itemID )
20118 {
20119 game->forced_bwpn = -1;
20120 } //not else if! -Z
20121
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if ( game->forced_awpn == itemID )
20122 {
20123 game->forced_awpn = -1;
20124 }
20125
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if ( game->forced_xwpn == itemID )
20126 {
20127 game->forced_xwpn = -1;
20128 } //not else if! -Z
20129
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if ( game->forced_ywpn == itemID )
20130 {
20131 game->forced_ywpn = -1;
20132 }
20133 11 verifyBothWeapons();
20134 11 return true;
20135 }
20136
20137 case MSGC_SFX:
20138 {
20139 22 sfx(args[0]);
20140 22 return true;
20141 }
20142
20143 case MSGC_MIDI:
20144 {
20145 7 int32_t music = args[0];
20146
20147
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 1 times.
7 if(music==0)
20148 1 music_stop();
20149 else
20150 6 jukebox(music+(ZC_MIDI_COUNT-1));
20151
20152 7 return true;
20153 }
20154
20155 case MSGC_FONT:
20156 {
20157 int fontid = args[0];
20158 int oh = text_height(msgfont);
20159 msgfont = get_zc_font(fontid);
20160 int nh = text_height(msgfont);
20161 int mh = std::max(oh,nh);
20162 if(mh > ssc_tile_hei_buf)
20163 ssc_tile_hei_buf = mh;
20164 return true;
20165 }
20166 case MSGC_RUN_FRZ_GENSCR:
20167 {
20168 word scr_id = args[0];
20169 bool force_redraw = args[1]!=0;
20170 if(force_redraw)
20171 {
20172 update_msgstr();
20173 draw_screen();
20174 }
20175 FFCore.runGenericFrozenEngine(scr_id);
20176 return true;
20177 }
20178 case MSGC_DRAWTILE:
20179 {
20180 int32_t tl = args[0];
20181 int32_t cs = args[1];
20182 int32_t t_wid = args[2];
20183 int32_t t_hei = args[3];
20184 int32_t fl = args[4];
20185
20186 if(cursor_x+MsgStrings[msgstr].hspace + t_wid > msg_w-msg_margins[right])
20187 {
20188 ssc_tile_hei = ssc_tile_hei_buf;
20189 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20190 ssc_tile_hei_buf = -1;
20191 cursor_y += thei + MsgStrings[msgstr].vspace;
20192 if(bottom_margin_clip()) return true;
20193 cursor_x=msg_margins[left];
20194 }
20195
20196 overtileblock16(msg_txt_bmp_buf, tl, cursor_x, cursor_y, (int32_t)ceil(t_wid/16.0), (int32_t)ceil(t_hei/16.0), cs, fl);
20197 ssc_tile_hei_buf = zc_max(ssc_tile_hei_buf, t_hei);
20198 cursor_x += MsgStrings[msgstr].hspace + t_wid;
20199 return true;
20200 }
20201
20202 case MSGC_GOTOIFRAND:
20203 {
20204 1 int32_t odds = args[0];
20205
20206 1 last_arg = 1;
20207
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(!odds || !(zc_oldrand()%odds))
20208 1 goto switched;
20209
20210 return true;
20211 }
20212
20213 case MSGC_GOTOIFSCREEND:
20214 {
20215 int32_t arg = args[0];
20216 int32_t d = zc_min(7,arg);
20217 int32_t s = ((get_currdmap())<<7) + msgscr->screen-(DMaps[get_currdmap()].type==dmOVERW ? 0 : DMaps[get_currdmap()].xoff);
20218 arg = args[1];
20219
20220 if(game->screen_d[s][d] >= arg)
20221 {
20222 last_arg = 2;
20223 goto switched;
20224 }
20225
20226 return true;
20227 }
20228
20229 case MSGC_GOTOIFGLOBALSTATE:
20230 {
20231 int32_t index = args[0];
20232 bool value = args[1];
20233
20234 if (unsigned(index) >= NUM_GSWITCHES)
20235 {
20236 Z_error("SCC: Global state %d is invalid\n", index);
20237 return true;
20238 }
20239
20240 bool state = game->gswitch_timers[index] != 0;
20241
20242 if (state == value)
20243 {
20244 last_arg = 2;
20245 goto switched;
20246 }
20247
20248 return true;
20249 }
20250
20251 case MSGC_SETGLOBALSTATE:
20252 {
20253 int32_t index = args[0];
20254 int32_t value = args[1];
20255
20256 if (unsigned(index) >= NUM_GSWITCHES)
20257 {
20258 Z_error("SCC: Global state %d is invalid\n", index);
20259 return true;
20260 }
20261
20262 if (bool(game->gswitch_timers[index]) != bool(value))
20263 toggle_gswitches(index, false);
20264 game->gswitch_timers[index] = value;
20265
20266 return true;
20267 }
20268
20269 case MSGC_GOTOIFSCREENSTATE:
20270 {
20271 int32_t flag = args[0];
20272 bool value = args[1];
20273
20274 if (unsigned(flag) >= mMAXIND)
20275 {
20276 Z_error("SCC: Screen state %d is invalid\n", flag);
20277 return true;
20278 }
20279
20280 bool state = getmapflag(msgscr, 1<<flag);
20281 if (state == value)
20282 {
20283 last_arg = 2;
20284 goto switched;
20285 }
20286
20287 return true;
20288 }
20289
20290 case MSGC_GOTOIFANYSCREENSTATE:
20291 {
20292 int32_t map = args[0];
20293 int32_t screen = args[1];
20294 int32_t flag = args[2];
20295 bool value = args[3];
20296
20297 if (unsigned(flag)>=mMAXIND)
20298 {
20299 Z_error("SCC: Screen state %d is invalid\n", flag);
20300 return true;
20301 }
20302
20303 if (map < 1 || map > map_count)
20304 {
20305 Z_error("SCC: Map %d is invalid\n", map);
20306 return true;
20307 }
20308
20309 if (unsigned(screen)>=0x80)
20310 {
20311 Z_error("SCC: Screen %d is invalid\n", screen);
20312 return true;
20313 }
20314
20315 int mi = mapind(map, screen);
20316 bool state = (game->maps[mi] & (1<<flag)) != 0;
20317 if (state == value)
20318 {
20319 last_arg = 4;
20320 goto switched;
20321 }
20322
20323 return true;
20324 }
20325
20326 case MSGC_GOTOIFSCREENEXSTATE:
20327 {
20328 int32_t flag = args[0];
20329 bool value = args[1];
20330
20331 if (unsigned(flag) >= 32)
20332 {
20333 Z_error("SCC: Screen ExState %d is invalid\n", flag);
20334 return true;
20335 }
20336
20337 bool state = getxmapflag(msgscr->screen, 1<<flag);
20338 if (state == value)
20339 {
20340 last_arg = 2;
20341 goto switched;
20342 }
20343
20344 return true;
20345 }
20346
20347 case MSGC_GOTOIFANYSCREENEXSTATE:
20348 {
20349 int32_t map = args[0];
20350 int32_t screen = args[1];
20351 int32_t flag = args[2];
20352 bool value = args[3];
20353
20354 if (unsigned(flag) >= 32)
20355 {
20356 Z_error("SCC: Screen ExState %d is invalid\n", flag);
20357 return true;
20358 }
20359
20360 if (map < 1 || map > map_count)
20361 {
20362 Z_error("SCC: Map %d is invalid\n", map);
20363 return true;
20364 }
20365
20366 if (unsigned(screen)>=0x80)
20367 {
20368 Z_error("SCC: Screen %d is invalid\n", screen);
20369 return true;
20370 }
20371
20372 bool state = getxmapflag(mapind(map, screen), 1<<flag);
20373 if (state == value)
20374 {
20375 last_arg = 4;
20376 goto switched;
20377 }
20378
20379 return true;
20380 }
20381
20382 case MSGC_GOTOIFLEVELSTATE:
20383 {
20384 int32_t level = args[0];
20385 int32_t flag = args[1];
20386 bool value = args[2];
20387
20388 if (level == -1)
20389 level = dlevel;
20390
20391 if (unsigned(level) >= game->lvlswitches.size())
20392 {
20393 Z_error("SCC: Level %d is invalid\n", level);
20394 return true;
20395 }
20396
20397 if (unsigned(flag) >= 32)
20398 {
20399 Z_error("SCC: Level state %d is invalid\n", flag);
20400 return true;
20401 }
20402
20403 bool state = game->lvlswitches[level] & (1<<flag);
20404 if (state == value)
20405 {
20406 last_arg = 3;
20407 goto switched;
20408 }
20409
20410 return true;
20411 }
20412
20413 case MSGC_SETLEVELSTATE:
20414 {
20415 int32_t level = args[0];
20416 int32_t flag = args[1];
20417 bool value = args[2];
20418
20419 if (level == -1)
20420 level = dlevel;
20421
20422 if (unsigned(level) >= game->lvlswitches.size())
20423 {
20424 Z_error("SCC: Level %d is invalid\n", level);
20425 return true;
20426 }
20427
20428 if (unsigned(flag) >= 32)
20429 {
20430 Z_error("SCC: Level state %d is invalid\n", flag);
20431 return true;
20432 }
20433
20434 if (level == dlevel)
20435 {
20436 if (bool(game->lvlswitches[level] & (1<<flag)) != value)
20437 toggle_switches(1<<flag, false);
20438 }
20439 else
20440 {
20441 SETFLAG(game->lvlswitches[level], 1<<flag, value);
20442 }
20443
20444 return true;
20445 }
20446
20447 case MSGC_GOTOIFLEVELITEM:
20448 {
20449 int32_t level = args[0];
20450 int32_t flag = args[1];
20451 bool value = args[2];
20452
20453 if (level == -1)
20454 level = dlevel;
20455
20456 if (unsigned(level) >= game->lvlitems.size())
20457 {
20458 Z_error("SCC: Level %d is invalid\n", level);
20459 return true;
20460 }
20461
20462 if (unsigned(flag) >= 16)
20463 {
20464 Z_error("SCC: Level item %d is invalid\n", flag);
20465 return true;
20466 }
20467
20468 bool state = game->lvlitems[level] & (1<<flag);
20469 if (state == value)
20470 {
20471 last_arg = 3;
20472 goto switched;
20473 }
20474
20475 return true;
20476 }
20477
20478 case MSGC_SETLEVELITEM:
20479 {
20480 int32_t level = args[0];
20481 int32_t flag = args[1];
20482 bool value = args[2];
20483
20484 if (level == -1)
20485 level = dlevel;
20486
20487 if (unsigned(level) >= game->lvlitems.size())
20488 {
20489 Z_error("SCC: Level %d is invalid\n", level);
20490 return true;
20491 }
20492
20493 if (unsigned(flag) >= 16)
20494 {
20495 Z_error("SCC: Level item %d is invalid\n", flag);
20496 return true;
20497 }
20498
20499 SETFLAG(game->lvlitems[level], 1<<flag, value);
20500
20501 return true;
20502 }
20503
20504 case MSGC_GOTOIFSECRETS:
20505 {
20506 if (get_screen_state(msgscr->screen).triggered_secrets)
20507 {
20508 last_arg = 0;
20509 goto switched;
20510 }
20511
20512 return true;
20513 }
20514
20515 case MSGC_GOTOIFCREEND:
20516 {
20517 int32_t dmap = (args[0]<<7); //dmap and screen may be transposed here.
20518 int32_t screen = args[1];
20519 int32_t reg = args[2];
20520 int32_t val = args[3];
20521 if ( FFCore.get_screen_d(screen + dmap, reg) >= val )
20522 {
20523 last_arg = 4;
20524 goto switched;
20525 }
20526 return true;
20527 }
20528
20529 case MSGC_GOTOIFITEM:
20530 {
20531 122 int32_t it = args[0];
20532
20533
3/4
✓ Branch 0 taken 122 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 87 times.
✓ Branch 3 taken 35 times.
122 if(unsigned(it)<MAXITEMS && game->item[it])
20534 {
20535 35 last_arg = 1;
20536 35 goto switched;
20537 }
20538
20539 87 return true;
20540 }
20541
20542 case MSGC_GOTOIFCTR:
20543 {
20544
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 14 times.
28 if(game->get_counter(args[0]) >= args[1])
20545 {
20546 14 last_arg = 2;
20547 14 goto switched;
20548 }
20549
20550 14 return true;
20551 }
20552
20553 case MSGC_GOTOIFCTRPC:
20554 {
20555 int32_t counter = args[0];
20556 int32_t amount = (int32_t)((args[1]/100)*game->get_maxcounter(counter));
20557
20558 if(game->get_counter(counter)>=amount)
20559 {
20560 last_arg = 2;
20561 goto switched;
20562 }
20563
20564 return true;
20565 }
20566
20567 case MSGC_GOTOIFTRICOUNT:
20568 {
20569 if(TriforceCount() >= args[0])
20570 {
20571 last_arg = 1;
20572 goto switched;
20573 }
20574
20575 return true;
20576 }
20577
20578 case MSGC_GOTOIFTRI:
20579 {
20580 int32_t lev = args[0];
20581
20582 if(lev<MAXLEVELS && game->lvlitems[lev]&(1 << li_mcguffin))
20583 {
20584 last_arg = 1;
20585 goto switched;
20586 }
20587
20588 return true;
20589 }
20590
20591 case MSGC_GOTOIFBOTTLE:
20592 {
20593 int quant = args[0];
20594 int type = args[1];
20595 if (game->hasBottle(type, quant))
20596 {
20597 last_arg = 2;
20598 goto switched;
20599 }
20600 return true;
20601 }
20602 case MSGC_CHANGEBOTTLE:
20603 {
20604 int quant = args[0];
20605 int old_type = args[1];
20606 int new_type = args[2];
20607 game->fillBottle(new_type, old_type, quant);
20608 return true;
20609 }
20610
20611 case MSGC_CHANGEPORTRAIT:
20612 {
20613 prt_tile = args[0];
20614 prt_cset = args[1];
20615 prt_x = args[2];
20616 prt_y = args[3];
20617 prt_tw = args[4];
20618 prt_th = args[5];
20619 msg_prt();
20620 return true;
20621 }
20622
20623 case MSGC_SETUPMENU:
20624 {
20625 5 msg_menu_data[MNU_CURSOR_TILE] = args[0];
20626 5 msg_menu_data[MNU_CURSOR_CSET] = args[1];
20627 5 msg_menu_data[MNU_CURSOR_WID] = args[2];
20628 5 msg_menu_data[MNU_CURSOR_HEI] = args[3];
20629 5 msg_menu_data[MNU_CURSOR_FLIP] = args[4];
20630 5 return true;
20631 }
20632
20633 case MSGC_MENUCHOICE:
20634 {
20635 18 int32_t pos = args[0];
20636 18 int32_t upos = args[1];
20637 18 int32_t dpos = args[2];
20638 18 int32_t lpos = args[3];
20639 18 int32_t rpos = args[4];
20640
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 2 times.
18 if(cursor_x+MsgStrings[msgstr].hspace + msg_menu_data[MNU_CURSOR_WID] > msg_w-msg_margins[right])
20641 {
20642 2 ssc_tile_hei = ssc_tile_hei_buf;
20643
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20644 2 ssc_tile_hei_buf = -1;
20645 2 cursor_y += thei + MsgStrings[msgstr].vspace;
20646
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(bottom_margin_clip()) break;
20647 2 cursor_x=msg_margins[left];
20648 2 }
20649
20650 36 menu_options[pos] = menu_choice(cursor_x, cursor_y, pos,
20651 18 upos, dpos, lpos, rpos);
20652
20653
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
18 ssc_tile_hei_buf = zc_max(ssc_tile_hei_buf, msg_menu_data[MNU_CURSOR_HEI]);
20654 18 cursor_x += MsgStrings[msgstr].hspace + msg_menu_data[MNU_CURSOR_WID];
20655 18 return true;
20656 }
20657
20658 case MSGC_RUNMENU:
20659 {
20660 5 msg_menu_data[MNU_CHOSEN] = 0;
20661 5 msg_menu_data[MNU_CAN_CONFIRM] = 0;
20662
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(menu_options.size() < 1)
20663 return true;
20664 5 do_run_menu = true;
20665 5 return true;
20666 }
20667
20668 case MSGC_GOTOMENUCHOICE:
20669 {
20670 7 int32_t choice = args[0];
20671
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2 times.
7 if(msg_menu_data[MNU_CHOSEN] == choice)
20672 {
20673 5 last_arg = 1;
20674 5 goto switched;
20675 }
20676
20677 2 return true;
20678 }
20679
20680 case MSGC_KILLHERO:
20681 {
20682 bool bypass_revive = args[0];
20683 Hero.kill(bypass_revive);
20684 return true;
20685 }
20686 case MSGC_ENDSTRING:
20687 {
20688 3 do_end_str = true;
20689 3 return true;
20690 }
20691 case MSGC_WAIT_ADVANCE:
20692 {
20693 wait_advance = true;
20694 linkedmsgclk = 51;
20695 return true;
20696 }
20697 case MSGC_DELAY:
20698 case MSGC_FORCE_DELAY:
20699 {
20700 2 int frames = args[0];
20701
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (frames <= 0)
20702 {
20703 Z_error("SCC: frames %d is invalid (must be >0)\n", frames);
20704 return true;
20705 }
20706
20707 2 msg_it->set_post_segment_delay(frames, command.code == MSGC_FORCE_DELAY);
20708 2 return true;
20709 }
20710 case MSGC_TRIGSECRETS:
20711 {
20712 bool perm = args[0];
20713 trigger_secrets_for_screen(TriggerSource::SCC, msgscr, false);
20714 if(perm)
20715 setmapflag(msgscr, mSECRET);
20716 return true;
20717 }
20718 case MSGC_TRIG_CMB_COPYCAT:
20719 {
20720 int copy_id = args[0];
20721 if(copy_id == byte(copy_id))
20722 trig_copycat(copy_id);
20723 return true;
20724 }
20725 case MSGC_SETSCREENSTATE:
20726 {
20727 int32_t flag = args[0];
20728 if(unsigned(flag)>=mMAXIND)
20729 {
20730 Z_error("SCC 133: State %d is invalid\n", flag);
20731 return true;
20732 }
20733 bool state = args[1];
20734 if(state)
20735 setmapflag(msgscr, 1<<flag);
20736 else
20737 unsetmapflag(msgscr, 1<<flag, true);
20738 return true;
20739 }
20740 case MSGC_SETSCREENSTATER:
20741 {
20742 int32_t map = args[0];
20743 int32_t scrid = args[1];
20744 if(map < 1 || map > map_count)
20745 {
20746 Z_error("SCC 134: Map %d is invalid\n", map);
20747 return true;
20748 }
20749 if(unsigned(scrid)>=0x80)
20750 {
20751 Z_error("SCC 134: Screen %d is invalid\n", scrid);
20752 return true;
20753 }
20754
20755 int32_t flag = args[2];
20756 if(unsigned(flag)>=mMAXIND)
20757 {
20758 Z_error("SCC 134: State %d is invalid\n", flag);
20759 return true;
20760 }
20761 bool state = args[3];
20762 if(state)
20763 setmapflag_mi(msgscr, mapind(map,scrid),1<<flag);
20764 else
20765 unsetmapflag_mi(msgscr, mapind(map,scrid),1<<flag,true);
20766 return true;
20767 }
20768
20769 case MSGC_SETANYSCREENEXSTATE:
20770 {
20771 int32_t map = args[0];
20772 int32_t screen = args[1];
20773 int32_t flag = args[2];
20774
20775 if (unsigned(flag) >= 32)
20776 {
20777 Z_error("SCC: Screen ExState %d is invalid\n", flag);
20778 return true;
20779 }
20780
20781 if (map < 1 || map > map_count)
20782 {
20783 Z_error("SCC: Map %d is invalid\n", map);
20784 return true;
20785 }
20786
20787 if (unsigned(screen)>=0x80)
20788 {
20789 Z_error("SCC: Screen %d is invalid\n", screen);
20790 return true;
20791 }
20792
20793 bool state = args[3];
20794 if(state)
20795 setxmapflag(mapind(map, screen), 1<<flag);
20796 else
20797 unsetxmapflag(mapind(map, screen), 1<<flag);
20798 return true;
20799 }
20800
20801 case MSGC_SETSCREENEXSTATE:
20802 {
20803 int32_t flag = args[0];
20804 if (unsigned(flag) >= 32)
20805 {
20806 Z_error("SCC: Screen ExState %d is invalid\n", flag);
20807 return true;
20808 }
20809
20810 bool state = args[1];
20811 if(state)
20812 setxmapflag(msgscr->screen, 1<<flag);
20813 else
20814 unsetxmapflag(msgscr->screen, 1<<flag);
20815 return true;
20816 }
20817
20818 switched:
20819 55 int32_t lev = args[last_arg];
20820
3/4
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
55 if(lev && get_qr(qr_SCC_GOTO_RESPECTS_CONTFLAG)
20821
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 33 times.
54 && (MsgStrings[lev].stringflags & STRINGFLAG_CONT))
20822 {
20823 setmsg(lev);
20824 }
20825 else
20826 {
20827 55 donewmsg(msgscr, lev);
20828 55 ssc_tile_hei_buf = -1;
20829 }
20830 55 putprices(false);
20831 55 return true;
20832 }
20833
20834 return false;
20835 3729 }
20836
20837 3739 static std::string parsemsgcode2(const StringCommand& command)
20838 {
20839
2/2
✓ Branch 0 taken 3733 times.
✓ Branch 1 taken 6 times.
3739 if (command.code == MSGC_NAME)
20840 {
20841
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 return game->get_name();
20842 }
20843
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 3731 times.
3733 else if (command.code == MSGC_COUNTER)
20844 {
20845 2 return fmt::format("{}", game->get_counter(command.args[0]));
20846 }
20847
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 3729 times.
3731 else if (command.code == MSGC_MAXCOUNTER)
20848 {
20849 2 return fmt::format("{}", game->get_maxcounter(command.args[0]));
20850 }
20851 else
20852 {
20853 3729 parsemsgcode(command);
20854 }
20855
20856
1/2
✓ Branch 0 taken 3729 times.
✗ Branch 1 not taken.
3729 return "";
20857 3739 }
20858
20859 292578 static bool putmsgchar(bool play_sfx)
20860 {
20861 DCHECK(msg_it->state == MsgStr::iterator::CHARACTER);
20862 DCHECK(!msg_it->character.empty());
20863
20864
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 292578 times.
292578 if (bottom_margin_clip())
20865 return false;
20866
20867 // If the current word would overflow the margins, increment cursor to the next line.
20868 292578 const char* rem_word = msg_it->remaining_word();
20869 292578 int tlength = text_length(msgfont, rem_word) + ((int32_t)strlen(rem_word)*MsgStrings[msgstr].hspace);
20870
4/4
✓ Branch 0 taken 6443 times.
✓ Branch 1 taken 286135 times.
✓ Branch 2 taken 1147 times.
✓ Branch 3 taken 5089 times.
298814 if (cursor_x+tlength > (msg_w-msg_margins[right]) &&
20871
4/4
✓ Branch 0 taken 6236 times.
✓ Branch 1 taken 207 times.
✓ Branch 2 taken 5089 times.
✓ Branch 3 taken 207 times.
6443 ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)) ? true : strcmp(rem_word," ")!=0))
20872 {
20873 6236 ssc_tile_hei = ssc_tile_hei_buf;
20874
1/2
✓ Branch 0 taken 6236 times.
✗ Branch 1 not taken.
6236 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20875 6236 ssc_tile_hei_buf = -1;
20876 6236 cursor_y += thei + MsgStrings[msgstr].vspace;
20877
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6236 times.
6236 if (bottom_margin_clip()) return false;
20878
20879 6236 cursor_x = msg_margins[left];
20880 6236 }
20881
20882
2/2
✓ Branch 0 taken 40236 times.
✓ Branch 1 taken 252342 times.
292578 if (play_sfx)
20883 252342 sfx(MsgStrings[msgstr].sfx);
20884
20885 // Print the character (unless it's just a space).
20886
2/2
✓ Branch 0 taken 66585 times.
✓ Branch 1 taken 225993 times.
292578 if (msg_it->character != " ")
20887 225993 textout_styled_aligned_ex(msg_txt_bmp_buf, msgfont, msg_it->character.c_str(), cursor_x, cursor_y, msg_shdtype, sstaLEFT, msgcolour, msg_shdcol, -1);
20888
20889 // Move the cursor.
20890 292578 cursor_x += msgfont->vtable->text_length(msgfont, msg_it->character.c_str());
20891
2/2
✓ Branch 0 taken 66585 times.
✓ Branch 1 taken 225993 times.
292578 if (msg_it->character != " ")
20892 225993 cursor_x += MsgStrings[msgstr].hspace;
20893
20894 292578 return true;
20895 292578 }
20896
20897 enum msg_tick_result {msg_tick_exit, msg_tick_break, msg_tick_continue};
20898
20899 static void msg_tick_end(bool disappear = false);
20900 281565 static msg_tick_result msg_tick(bool play_sfx, bool burst_mode)
20901 {
20902
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 281565 times.
281565 if (msg_it->done())
20903 return msg_tick_exit;
20904
20905
2/2
✓ Branch 0 taken 2045 times.
✓ Branch 1 taken 279520 times.
281565 if (!do_run_menu)
20906 {
20907
4/4
✓ Branch 0 taken 279515 times.
✓ Branch 1 taken 3739 times.
✓ Branch 2 taken 279515 times.
✓ Branch 3 taken 3739 times.
283254 while (msg_it->state == MsgStr::iterator::COMMAND && !do_run_menu)
20908 {
20909 3739 bool one_frame_command_delay = !replay_version_check(41);
20910 3739 std::string text = parsemsgcode2(msg_it->command);
20911
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3739 times.
3739 if (wait_advance)
20912 break;
20913
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 3734 times.
3739 if (do_run_menu)
20914 {
20915
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 msg_it->set_buffer("");
20916 5 break;
20917 }
20918
20919
2/2
✓ Branch 0 taken 3724 times.
✓ Branch 1 taken 10 times.
3734 if (text.empty())
20920 {
20921
2/4
✓ Branch 0 taken 3724 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3724 times.
✗ Branch 3 not taken.
3724 msg_it->set_buffer("");
20922 // Advance the iterator to run many commands in one frame.
20923
2/2
✓ Branch 0 taken 613 times.
✓ Branch 1 taken 3111 times.
3724 if (!one_frame_command_delay)
20924
1/2
✓ Branch 0 taken 613 times.
✗ Branch 1 not taken.
613 msg_it->next();
20925 3724 }
20926 else
20927 {
20928
2/4
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
10 msg_it->set_buffer(text);
20929
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 msg_it->next();
20930
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 4 times.
10 if (one_frame_command_delay)
20931
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 msg_it->set_post_segment_delay(1, false);
20932 }
20933
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 3734 times.
3739 }
20934
20935
2/2
✓ Branch 0 taken 3389 times.
✓ Branch 1 taken 276131 times.
279520 if (msg_it->state == MsgStr::iterator::CHARACTER)
20936 {
20937
1/2
✓ Branch 0 taken 276131 times.
✗ Branch 1 not taken.
276131 if (!putmsgchar(play_sfx)) return msg_tick_break;
20938 276131 }
20939 279520 }
20940
20941 281565 bool wait_advance_check_early = !burst_mode;
20942
20943
2/2
✓ Branch 0 taken 105463 times.
✓ Branch 1 taken 176102 times.
281565 if (wait_advance_check_early)
20944 {
20945
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 176101 times.
176102 if (do_end_str)
20946 {
20947 1 msg_tick_end();
20948 1 return msg_tick_exit;
20949 }
20950
20951
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 176101 times.
176101 if (wait_advance)
20952 {
20953 msg_it->next();
20954 return msg_tick_exit;
20955 }
20956 176101 }
20957
20958
2/2
✓ Branch 0 taken 279514 times.
✓ Branch 1 taken 2050 times.
281564 if (do_run_menu)
20959 {
20960
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2045 times.
2050 if (runMenuCursor())
20961 {
20962 5 do_run_menu = false;
20963
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2 times.
5 if (!burst_mode)
20964 {
20965 2 msg_it->next();
20966 2 return msg_tick(play_sfx, burst_mode);
20967 }
20968 3 }
20969 2045 else return msg_tick_break;
20970 3 }
20971
20972 279517 msg_it->next();
20973
20974
2/2
✓ Branch 0 taken 174595 times.
✓ Branch 1 taken 104922 times.
279517 if (!wait_advance_check_early)
20975 {
20976
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 104920 times.
104922 if (do_end_str)
20977 {
20978 2 msg_tick_end();
20979 2 return msg_tick_exit;
20980 }
20981
20982
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104920 times.
104920 if (wait_advance)
20983 return msg_tick_exit;
20984 104920 }
20985
20986
4/4
✓ Branch 0 taken 4387 times.
✓ Branch 1 taken 275128 times.
✓ Branch 2 taken 2121 times.
✓ Branch 3 taken 2266 times.
279515 if (msg_it->done() && MsgStrings[msgstr].nextstring)
20987 {
20988
1/2
✓ Branch 0 taken 2121 times.
✗ Branch 1 not taken.
2121 if (MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
20989 setmsg(MsgStrings[msgstr].nextstring);
20990 2121 }
20991
20992 279515 return msg_tick_continue;
20993 281565 }
20994
20995 178950 static void msg_tick_end(bool disappear)
20996 {
20997
2/2
✓ Branch 0 taken 177661 times.
✓ Branch 1 taken 1289 times.
178950 if (disappear)
20998 1289 goto disappear;
20999
21000 // Done printing the string
21001
8/8
✓ Branch 0 taken 177658 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 176154 times.
✓ Branch 3 taken 1504 times.
✓ Branch 4 taken 171748 times.
✓ Branch 5 taken 4406 times.
✓ Branch 6 taken 171748 times.
✓ Branch 7 taken 4406 times.
177661 if (do_end_str || !do_run_menu && (msg_it->done() || bottom_margin_clip()) && !linkedmsgclk)
21002 {
21003
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 4406 times.
4409 if(!do_end_str)
21004 {
21005
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4406 times.
4406 while (msg_it->state == MsgStr::iterator::COMMAND)
21006 {
21007 parsemsgcode2(msg_it->command);
21008 msg_it->next();
21009 }
21010 4406 }
21011
21012 // Go to next string, or make it disappear by going to string 0.
21013
5/6
✓ Branch 0 taken 2286 times.
✓ Branch 1 taken 2123 times.
✓ Branch 2 taken 996 times.
✓ Branch 3 taken 1290 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 996 times.
4409 if(MsgStrings[msgstr].nextstring!=0 || get_qr(qr_MSGDISAPPEAR) || enqueued_str)
21014 {
21015 3413 linkedmsgclk=do_end_str?1:51;
21016 3413 }
21017
21018
2/2
✓ Branch 0 taken 2286 times.
✓ Branch 1 taken 2123 times.
4409 if(MsgStrings[msgstr].nextstring==0)
21019 {
21020
2/2
✓ Branch 0 taken 1290 times.
✓ Branch 1 taken 996 times.
2286 if(!get_qr(qr_MSGDISAPPEAR))
21021 996 {
21022 disappear:
21023 2285 msg_active = false;
21024 2285 Hero.finishedmsg();
21025 2285 }
21026
21027
2/2
✓ Branch 0 taken 3562 times.
✓ Branch 1 taken 13 times.
3575 if(repaircharge)
21028 {
21029
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 game->change_drupy(-(cur_screen >= 128 ? special_warp_return_scr : msgscr)->catchall);
21030 13 repaircharge = 0;
21031 13 }
21032
21033
2/2
✓ Branch 0 taken 3573 times.
✓ Branch 1 taken 2 times.
3575 if(adjustmagic)
21034 {
21035
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(get_qr(qr_OLD_HALF_MAGIC))
21036 {
21037
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(game->get_magicdrainrate())
21038 2 game->set_magicdrainrate(1);
21039 2 }
21040 else if(game->get_magicdrainrate() > 1)
21041 {
21042 game->set_magicdrainrate(game->get_magicdrainrate()/2);
21043 }
21044 2 adjustmagic = false;
21045 2 sfx(WAV_SCALE);
21046
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 setmapflag(msgscr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
21047 2 }
21048
21049
2/2
✓ Branch 0 taken 3573 times.
✓ Branch 1 taken 2 times.
3575 if(learnslash)
21050 {
21051 2 game->set_canslash(1);
21052 2 learnslash = false;
21053 2 sfx(WAV_SCALE);
21054
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 setmapflag(msgscr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
21055 2 }
21056 3575 }
21057 5698 }
21058 178950 }
21059
21060 6616 static void msg_consume_spaces()
21061 {
21062
2/2
✓ Branch 0 taken 6616 times.
✓ Branch 1 taken 16447 times.
23063 while (msg_it->character == " ")
21063 {
21064
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16447 times.
16447 if (!putmsgchar(false)) break;
21065
21066 // Advance the iterator.
21067 16447 msg_it->next();
21068
21069 // The "Continue From Previous" feature
21070
1/2
✓ Branch 0 taken 16447 times.
✗ Branch 1 not taken.
16447 if (msg_it->state == MsgStr::iterator::DONE)
21071 {
21072 if(MsgStrings[msgstr].nextstring)
21073 {
21074 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
21075 {
21076 setmsg(MsgStrings[msgstr].nextstring);
21077 }
21078 }
21079 }
21080 }
21081 6616 }
21082
21083 15196991 void putmsg()
21084 {
21085
2/2
✓ Branch 0 taken 733232 times.
✓ Branch 1 taken 14463759 times.
15196991 if(!msgorig) msgorig=msgstr;
21086
21087
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15196991 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
15196991 if(wait_advance && linkedmsgclk < 1)
21088 linkedmsgclk = 1;
21089
2/2
✓ Branch 0 taken 14884012 times.
✓ Branch 1 taken 312979 times.
15196991 if(linkedmsgclk>0)
21090 {
21091
2/2
✓ Branch 0 taken 142528 times.
✓ Branch 1 taken 170451 times.
312979 if(linkedmsgclk==1)
21092 {
21093
6/6
✓ Branch 0 taken 142525 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 139253 times.
✓ Branch 3 taken 3272 times.
✓ Branch 4 taken 136 times.
✓ Branch 5 taken 139117 times.
142528 if(do_end_str||cAbtn()||cBbtn())
21094 {
21095 3411 do_end_str = false;
21096 3411 linkedmsgclk = 0;
21097
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3411 times.
3411 if(wait_advance)
21098 {
21099 wait_advance = false;
21100 }
21101 else
21102 {
21103
1/2
✓ Branch 0 taken 3411 times.
✗ Branch 1 not taken.
3411 if (!msgscr) msgscr = hero_scr;
21104 3411 msgstr=MsgStrings[msgstr].nextstring;
21105 3411 ssc_tile_hei_buf = -1;
21106
3/4
✓ Branch 0 taken 1289 times.
✓ Branch 1 taken 2122 times.
✓ Branch 2 taken 1289 times.
✗ Branch 3 not taken.
3411 if(!msgstr && enqueued_str)
21107 {
21108 msgstr = enqueued_str;
21109 enqueued_str = 0;
21110 }
21111
2/2
✓ Branch 0 taken 2122 times.
✓ Branch 1 taken 1289 times.
3411 if(!msgstr)
21112 {
21113 1289 msgfont=get_zc_font(font_zfont);
21114
21115
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1285 times.
1289 if(msgscr->room!=rGRUMBLE)
21116 1285 blockpath=false;
21117
21118 1289 dismissmsg();
21119 1289 msg_tick_end(true);
21120 1289 return;
21121 }
21122
21123 2122 donewmsg(msgscr, msgstr);
21124 2122 putprices(false);
21125 }
21126 2122 }
21127 141239 }
21128 else
21129 {
21130 170451 --linkedmsgclk;
21131 }
21132 311690 }
21133
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15195702 times.
15195702 if(wait_advance) return; //Waiting for buttonpress
21134
21135
9/10
✓ Branch 0 taken 15194076 times.
✓ Branch 1 taken 1626 times.
✓ Branch 2 taken 728099 times.
✓ Branch 3 taken 14465977 times.
✓ Branch 4 taken 280722 times.
✓ Branch 5 taken 447377 times.
✓ Branch 6 taken 276317 times.
✓ Branch 7 taken 4405 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 276317 times.
15195702 if(!do_run_menu && (!msgstr || !msg_it || msg_it->done() || bottom_margin_clip()))
21136 {
21137
2/2
✓ Branch 0 taken 451782 times.
✓ Branch 1 taken 14465977 times.
14917759 if(!msgstr)
21138 14465977 msgorig=0;
21139
21140 14917759 msg_active = false;
21141 14917759 msg_it.reset();
21142 14917759 return;
21143 }
21144
21145
1/2
✓ Branch 0 taken 277943 times.
✗ Branch 1 not taken.
277943 if (!msg_it)
21146 return;
21147
21148 277943 msg_onscreen = true; // Now the message is onscreen (see donewmsg()).
21149
21150
2/2
✓ Branch 0 taken 273514 times.
✓ Branch 1 taken 4429 times.
277943 if (msg_it->state == MsgStr::iterator::NOT_STARTED)
21151 {
21152 4429 msg_it->next();
21153 4429 msg_consume_spaces();
21154 4429 }
21155
21156 // If the player is holding down the B button, or if msgspeed is 0, process as many characters
21157 // as possible. This skips the character-by-character animation that usually renders a string
21158 // slowly over many frames.
21159
4/4
✓ Branch 0 taken 1666 times.
✓ Branch 1 taken 276277 times.
✓ Branch 2 taken 275713 times.
✓ Branch 3 taken 564 times.
277943 if ((cBbtn() && get_qr(qr_ALLOWMSGBYPASS)) || msgspeed == 0)
21160 {
21161
2/2
✓ Branch 0 taken 1559 times.
✓ Branch 1 taken 105469 times.
107150 while (!msg_it->done())
21162 {
21163
5/6
✓ Branch 0 taken 47639 times.
✓ Branch 1 taken 57830 times.
✓ Branch 2 taken 47633 times.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 47633 times.
✗ Branch 5 not taken.
105469 if (msgspeed && !(cBbtn() && get_qr(qr_ALLOWMSGBYPASS)))
21164 6 goto breakout; // break out if message speed was changed to non-zero
21165
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 105463 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
105463 if (msg_it->get_post_segment_delay() && msg_it->get_post_segment_delay_forced())
21166 goto breakout; // or if a ForceDelay command was hit.
21167
21168 105463 auto tick = msg_tick(msg_it->character != " ", true);
21169
2/2
✓ Branch 0 taken 104922 times.
✓ Branch 1 taken 541 times.
105463 if (tick == msg_tick_break)
21170 541 break;
21171
2/2
✓ Branch 0 taken 104920 times.
✓ Branch 1 taken 2 times.
104922 if (tick == msg_tick_exit)
21172 2 return;
21173 }
21174
21175
2/2
✓ Branch 0 taken 541 times.
✓ Branch 1 taken 1559 times.
2100 if (!do_run_menu)
21176 {
21177 1559 msgclk = 72;
21178 1559 }
21179 2100 }
21180 else
21181 275713 {
21182 breakout:
21183 275719 word tempspeed = msgspeed;
21184
2/2
✓ Branch 0 taken 70445 times.
✓ Branch 1 taken 205274 times.
275719 bool go_fast = get_qr(qr_ALLOWFASTMSG) && cAbtn();
21185
2/2
✓ Branch 0 taken 274756 times.
✓ Branch 1 taken 963 times.
275719 if (do_run_menu)
21186 963 tempspeed = 0;
21187
6/6
✓ Branch 0 taken 275450 times.
✓ Branch 1 taken 269 times.
✓ Branch 2 taken 275450 times.
✓ Branch 3 taken 269 times.
✓ Branch 4 taken 275483 times.
✓ Branch 5 taken 236 times.
275719 if (msg_it->get_post_segment_delay() && msg_it->peek(0).empty())
21188 {
21189 236 tempspeed = 0;
21190 236 msg_it->set_post_segment_delay_fast(go_fast);
21191 236 }
21192
4/4
✓ Branch 0 taken 216620 times.
✓ Branch 1 taken 59099 times.
✓ Branch 2 taken 116460 times.
✓ Branch 3 taken 100160 times.
275719 if ((msgclk++ % (tempspeed+1) < tempspeed) && !go_fast)
21193 100160 return;
21194 }
21195
21196 // Process the next msg tick.
21197 // This will either print a single character, or process a single string command (with one
21198 // exception).
21199
3/4
✓ Branch 0 taken 176100 times.
✓ Branch 1 taken 1559 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 176100 times.
177659 if (!msg_it->done() && !bottom_margin_clip())
21200 {
21201 // This may run an additional tick in the case of a string menu finishing: the first
21202 // tick wraps up the menu, and then a second tick processes the next character or command.
21203 176100 auto tick = msg_tick(true, false);
21204
2/2
✓ Branch 0 taken 1504 times.
✓ Branch 1 taken 174596 times.
176100 if (tick == msg_tick_break)
21205 {
21206 1504 msg_tick_end();
21207 1504 return;
21208 }
21209
2/2
✓ Branch 0 taken 174595 times.
✓ Branch 1 taken 1 times.
174596 if (tick == msg_tick_exit)
21210 1 return;
21211
21212 // If the next two characters are spaces, consume all upcoming spaces now.
21213
13/20
✓ Branch 0 taken 2847 times.
✓ Branch 1 taken 171748 times.
✓ Branch 2 taken 171748 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 28495 times.
✓ Branch 5 taken 143253 times.
✓ Branch 6 taken 28495 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 28495 times.
✓ Branch 10 taken 146100 times.
✓ Branch 11 taken 28495 times.
✓ Branch 12 taken 2847 times.
✓ Branch 13 taken 171748 times.
✓ Branch 14 taken 172408 times.
✓ Branch 15 taken 2187 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
203090 if (!msg_it->done() && msg_it->peek(0) == " " && msg_it->peek(1) == " ")
21214 2187 msg_consume_spaces();
21215 174595 }
21216
21217 176154 msg_tick_end();
21218 15196869 }
21219
21220 140533 int32_t message_more_y()
21221 {
21222 //Is the flag ticked, do we really want a message more y larger than 160?
21223
5/6
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 140505 times.
✓ Branch 2 taken 140533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 140505 times.
✓ Branch 5 taken 28 times.
140533 int32_t msgy=zc_min((zinit.msg_more_is_offset==0)?zinit.msg_more_y:zinit.msg_more_y+MsgStrings[msgstr].y ,160);
21224 140533 msgy+=playing_field_offset;
21225 140533 return msgy;
21226 }
21227
21228 /*** Collision detection & handling ***/
21229
21230 14834064 void clear_script_one_frame_conditions()
21231 {
21232
2/2
✓ Branch 0 taken 40035761 times.
✓ Branch 1 taken 14834064 times.
54869825 for(int32_t j=0; j<guys.Count(); j++)
21233 {
21234 40035761 enemy *e = (enemy*)guys.spr(j);
21235
2/2
✓ Branch 0 taken 680607937 times.
✓ Branch 1 taken 40035761 times.
720643698 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) e->hitby[q] = 0;
21236 40035761 }
21237 14834064 }
21238
21239 6332453 void check_enemy_lweapon_collision(weapon *w)
21240 {
21241
8/8
✓ Branch 0 taken 5631760 times.
✓ Branch 1 taken 700693 times.
✓ Branch 2 taken 4578754 times.
✓ Branch 3 taken 1053006 times.
✓ Branch 4 taken 4511180 times.
✓ Branch 5 taken 67574 times.
✓ Branch 6 taken 16738 times.
✓ Branch 7 taken 4494442 times.
6332453 if(!(w->Dead()) && w->id!=wSword && w->id!=wHammer && w->id!=wWand)
21242 {
21243
2/2
✓ Branch 0 taken 4478385 times.
✓ Branch 1 taken 14286019 times.
18764404 for(int32_t j=0; j<guys.Count(); j++)
21244 {
21245 14286019 enemy *e = (enemy*)guys.spr(j);
21246
21247 14286019 bool didhit = e->hit(w);
21248 //boomerangs and such that last for more than a frame can write hitby[] for more than one frame,
21249 //because this only checks `if(dying || clk<0 || hclk>0 || superman)`
21250
2/2
✓ Branch 0 taken 14057767 times.
✓ Branch 1 taken 228252 times.
14286019 if(didhit)
21251 {
21252 // !(e->stunclk)
21253 228252 int32_t h = e->takehit(w);
21254
2/2
✓ Branch 0 taken 193222 times.
✓ Branch 1 taken 35030 times.
228252 if (h < 0) // hitby code
21255 {
21256 35030 int indx = Lwpns.find(w);
21257
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35030 times.
35030 if(indx > -1)
21258 35030 e->hitby[HIT_BY_LWEAPON] = indx+1;
21259 35030 e->hitby[HIT_BY_LWEAPON_UID] = w->getUID();
21260 35030 e->hitby[HIT_BY_LWEAPON_TYPE] = w->id;
21261
2/2
✓ Branch 0 taken 32565 times.
✓ Branch 1 taken 2465 times.
35030 if (w->parentitem > -1) e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = itemsbuf[w->parentitem].type;
21262 2465 else e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = -1;
21263 35030 e->hitby[HIT_BY_LWEAPON_PARENT_ID] = w->parentitem;
21264 35030 e->hitby[HIT_BY_LWEAPON_ENGINE_UID] = w->getUID();
21265 //we may need to handle this in special cases. -Z
21266 // arrow item pierce flag, for example -Em
21267 35030 }
21268
21269
2/2
✓ Branch 0 taken 35030 times.
✓ Branch 1 taken 193222 times.
228252 if(h < 0) // hit, check if weapon is "out of pierces"
21270 35030 w->hit_pierce(e, h);
21271
2/2
✓ Branch 0 taken 182588 times.
✓ Branch 1 taken 10634 times.
193222 else if(h > 0) // blocked
21272 10634 w->onhit(false, e, h);
21273
2/2
✓ Branch 0 taken 225578 times.
✓ Branch 1 taken 2674 times.
228252 if(abs(h) == 2)
21274 2674 break; // some enemy classes force a weapon hitting them to "wait a frame"
21275 225578 }
21276
21277
2/2
✓ Branch 0 taken 14269962 times.
✓ Branch 1 taken 13383 times.
14283345 if(w->Dead())
21278 {
21279 13383 break;
21280 }
21281 14269962 }
21282
21283 // Item flags added in 2.55:
21284 // BRang/HShot/Arrows item_flag4 is "Pick up anything" (port of qr_BRANGPICKUP)
21285 // BRang/HShot item_flag5 is "Drags Items" (port of qr_Z3BRANG_HSHOT)
21286 // Arrows item_flag2 is "Picks up items" (inverse port of qr_Z3BRANG_HSHOT)
21287 // -Em
21288
6/6
✓ Branch 0 taken 4031962 times.
✓ Branch 1 taken 462480 times.
✓ Branch 2 taken 3987048 times.
✓ Branch 3 taken 44914 times.
✓ Branch 4 taken 58271 times.
✓ Branch 5 taken 3928777 times.
4494442 if(w->id == wBrang || w->id == wHookshot || w->id == wArrow)
21289 {
21290 565665 int32_t itype, pitem = w->parentitem;
21291
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 462480 times.
✓ Branch 2 taken 58271 times.
✓ Branch 3 taken 44914 times.
565665 switch(w->id)
21292 {
21293 462480 case wBrang: itype = itype_brang; break;
21294 58271 case wArrow: itype = itype_arrow; break;
21295 case wHookshot:
21296 44914 itype = (w->family_class == itype_switchhook ? itype_switchhook :itype_hookshot);
21297 44914 break;
21298 }
21299
2/2
✓ Branch 0 taken 550738 times.
✓ Branch 1 taken 14927 times.
565665 if(pitem < 0) pitem = current_item_id(itype);
21300
5/6
✓ Branch 0 taken 44914 times.
✓ Branch 1 taken 520751 times.
✓ Branch 2 taken 100 times.
✓ Branch 3 taken 44814 times.
✓ Branch 4 taken 100 times.
✗ Branch 5 not taken.
565665 if(w->id == wHookshot && w->family_class == itype_switchhook && (itemsbuf[pitem].flags & item_flag9))
21301 { //Swap with item
21302 for(int32_t j=0; j<items.Count(); j++)
21303 {
21304 if(items.spr(j)->hit(w))
21305 {
21306 item *theItem = ((item*)items.spr(j));
21307 bool priced = theItem->PriceIndex >-1;
21308 bool isKey = itemsbuf[theItem->id].type==itype_key||itemsbuf[theItem->id].type==itype_lkey;
21309 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= game->get_item_spawn_flicker())
21310 || (((itemsbuf[w->parentitem].flags & item_flag4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[w->parentitem].flags & item_flag7)&&isKey)) && !priced && !(theItem->pickup & ipDUMMY))))
21311 {
21312 if(!Hero.switchhookclk)
21313 {
21314 hooked_comborpos = rpos_t::None;
21315 hooked_layerbits = 0;
21316 switching_object = theItem;
21317 theItem->switch_hooked = true;
21318 w->misc = 2;
21319 w->step = 0;
21320 theItem->clk2 = game->get_item_timeout_dur() / 2;
21321 Hero.doSwitchHook(game->get_switchhookstyle());
21322 if(QMisc.miscsfx[sfxSWITCHED])
21323 sfx(QMisc.miscsfx[sfxSWITCHED],pan(w->x));
21324 }
21325 }
21326 }
21327 }
21328 }
21329
6/6
✓ Branch 0 taken 58271 times.
✓ Branch 1 taken 507394 times.
✓ Branch 2 taken 374939 times.
✓ Branch 3 taken 316668 times.
✓ Branch 4 taken 507394 times.
✓ Branch 5 taken 316668 times.
565665 else if((w->id==wArrow&&itemsbuf[pitem].flags & item_flag2)||(w->id!=wArrow&&!(itemsbuf[pitem].flags & item_flag5)))//An arrow with "Picks up items" or a BRang/HShot without "Drags items"
21330 {
21331
2/2
✓ Branch 0 taken 88886 times.
✓ Branch 1 taken 374939 times.
463825 for(int32_t j=0; j<items.Count(); j++)
21332 {
21333
2/2
✓ Branch 0 taken 83988 times.
✓ Branch 1 taken 4898 times.
88886 if(items.spr(j)->hit(w))
21334 {
21335 4898 item *theItem = ((item*)items.spr(j));
21336 4898 bool priced = theItem->PriceIndex >-1;
21337
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 4766 times.
4898 bool isKey = itemsbuf[theItem->id].type==itype_key||itemsbuf[theItem->id].type==itype_lkey;
21338
5/8
✓ Branch 0 taken 4898 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4898 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3789 times.
✓ Branch 5 taken 1109 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2065 times.
6963 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= game->get_item_spawn_flicker())
21339
4/6
✓ Branch 0 taken 3174 times.
✓ Branch 1 taken 2065 times.
✓ Branch 2 taken 3174 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3174 times.
4898 || (((itemsbuf[pitem].flags & item_flag4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[pitem].flags & item_flag7)&&isKey))&& !priced)))
21340 {
21341
1/2
✓ Branch 0 taken 1724 times.
✗ Branch 1 not taken.
5854 if(itemsbuf[theItem->id].collect_script)
21342 {
21343 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[theItem->id].collect_script, theItem->id & 0xFFF);
21344 }
21345
21346 1724 Hero.checkitems(j);
21347 1724 }
21348 4898 }
21349 88886 }
21350 374939 }
21351
2/2
✓ Branch 0 taken 29180 times.
✓ Branch 1 taken 161546 times.
824062 else if(w->id!=wArrow) //A BRang/HShot with "Drags Items"
21352 {
21353
2/2
✓ Branch 0 taken 38285 times.
✓ Branch 1 taken 161546 times.
199831 for(int32_t j=0; j<items.Count(); j++)
21354 {
21355
2/2
✓ Branch 0 taken 29347 times.
✓ Branch 1 taken 8938 times.
38285 if(items.spr(j)->hit(w))
21356 {
21357 8938 item *theItem = ((item*)items.spr(j));
21358 8938 bool priced = theItem->PriceIndex >-1;
21359
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 8931 times.
8938 bool isKey = itemsbuf[theItem->id].type==itype_key||itemsbuf[theItem->id].type==itype_lkey;
21360
4/6
✓ Branch 0 taken 8938 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8938 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8655 times.
✓ Branch 5 taken 283 times.
8938 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= game->get_item_spawn_flicker())
21361
5/10
✓ Branch 0 taken 7455 times.
✓ Branch 1 taken 1200 times.
✓ Branch 2 taken 1483 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1483 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1483 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
8938 || (((itemsbuf[pitem].flags & item_flag4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[pitem].flags & item_flag7)&&isKey)) && !priced && !(theItem->pickup & ipDUMMY))))
21362 {
21363 7455 int32_t pickup = theItem->pickup;
21364 7455 int32_t id2 = theItem->id;
21365 7455 int32_t pstr = theItem->pstring;
21366 7455 int32_t pstr_flags = theItem->pickup_string_flags;
21367
21368 7455 std::vector<int32_t> &ev = FFCore.eventData;
21369 7455 ev.clear();
21370 7455 ev.push_back(id2*10000);
21371 7455 ev.push_back(pickup*10000);
21372 7455 ev.push_back(pstr*10000);
21373 7455 ev.push_back(pstr_flags*10000);
21374 7455 ev.push_back(0);
21375 7455 ev.push_back(theItem->getUID());
21376 7455 ev.push_back(GENEVT_ICTYPE_RANGED_DRAG*10000);
21377 7455 ev.push_back(w->getUID());
21378
21379 7455 throwGenScriptEvent(GENSCR_EVENT_COLLECT_ITEM);
21380 7455 bool nullify = ev[4] != 0;
21381
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7455 times.
7455 if(nullify) continue;
21382
2/2
✓ Branch 0 taken 1076 times.
✓ Branch 1 taken 6379 times.
7455 if(w->id == wBrang)
21383 {
21384 6379 w->onhit(false);
21385 6379 }
21386
21387
2/2
✓ Branch 0 taken 6951 times.
✓ Branch 1 taken 504 times.
7455 if(w->dragging==-1)
21388 {
21389 504 w->dead=1;
21390 504 theItem->clk2 = game->get_item_timeout_dur() / 2;
21391 504 w->dragging=j;
21392 504 theItem->is_dragged = true;
21393 504 }
21394 7455 }
21395 8938 }
21396 38285 }
21397 161546 }
21398 565665 }
21399 4494442 }
21400 6332453 }
21401 14831861 void check_collisions()
21402 {
21403
2/2
✓ Branch 0 taken 6332418 times.
✓ Branch 1 taken 14831861 times.
21164279 for(uint q = 0; q < Lwpns.Count(); ++q)
21404 6332418 check_enemy_lweapon_collision((weapon*)Lwpns.spr(q));
21405 14831861 }
21406
21407 14834064 void dragging_item()
21408 {
21409
2/2
✓ Branch 0 taken 6531126 times.
✓ Branch 1 taken 14834064 times.
21365190 for(int32_t i=0; i<Lwpns.Count(); i++)
21410 {
21411 6531126 weapon *w = (weapon*)Lwpns.spr(i);
21412
21413
4/4
✓ Branch 0 taken 6059972 times.
✓ Branch 1 taken 471154 times.
✓ Branch 2 taken 6367520 times.
✓ Branch 3 taken 163606 times.
6531126 if((w->id == wBrang || w->id==wHookshot)&&itemsbuf[w->parentitem].flags & item_flag5)//item_flag5 is a port for qr_Z3BRANG_HSHOT
21414 {
21415
3/4
✓ Branch 0 taken 7429 times.
✓ Branch 1 taken 156177 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7429 times.
163606 if(w->dragging>=0 && w->dragging<items.Count())
21416 {
21417 7429 item* dragItem = (item*)items.spr(w->dragging);
21418 7429 dragItem->x=w->x;
21419 7429 dragItem->y=w->y;
21420
21421 // Drag the Fairy enemy as well as the Fairy item
21422 7429 int32_t id = dragItem->id;
21423
21424
4/4
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 7010 times.
✓ Branch 2 taken 404 times.
✓ Branch 3 taken 15 times.
7429 if(itemsbuf[id].type ==itype_fairy && itemsbuf[id].misc3)
21425 {
21426 404 movefairynew2(w->x,w->y,*dragItem);
21427 404 }
21428 7429 }
21429 163606 }
21430 6531126 }
21431 14834064 }
21432
21433 64 int32_t more_carried_items(int screen)
21434 {
21435 64 int32_t hasmorecarries = 0;
21436
21437
2/2
✓ Branch 0 taken 71 times.
✓ Branch 1 taken 64 times.
135 for(int32_t i=0; i<items.Count(); i++)
21438 {
21439 71 auto spr = (item*)items.spr(i);
21440
4/4
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 64 times.
71 if (spr->screen_spawned == screen && (spr->pickup & ipENEMY))
21441 {
21442 64 hasmorecarries++;
21443 64 }
21444 71 }
21445
21446 64 return hasmorecarries;
21447 }
21448
21449 43413 static int count_guys_from_screen(int screen)
21450 {
21451 43413 int count = 0;
21452
2/2
✓ Branch 0 taken 244979 times.
✓ Branch 1 taken 43413 times.
288392 for (int i=0; i < guys.Count(); i++)
21453 {
21454
2/2
✓ Branch 0 taken 36538 times.
✓ Branch 1 taken 208441 times.
244979 if (((enemy*)guys.spr(i))->screen_spawned == screen)
21455 208441 count += 1;
21456 244979 }
21457 43413 return count;
21458 }
21459
21460 // messy code to do the enemy-carrying-the-item thing
21461 15221992 static void roaming_item(mapscr* scr)
21462 {
21463 15221992 int screen = scr->screen;
21464 15221992 auto& state = get_screen_state(screen);
21465
4/4
✓ Branch 0 taken 15178648 times.
✓ Branch 1 taken 43344 times.
✓ Branch 2 taken 15178579 times.
✓ Branch 3 taken 43413 times.
15221992 if (!(state.item_state == ScreenItemState::CarriedByEnemy || state.item_state == ScreenItemState::MustGiveToEnemy) || !state.loaded_enemies)
21466 15178579 return;
21467
21468 // All enemies already dead upon entering a room?
21469
1/2
✓ Branch 0 taken 43413 times.
✗ Branch 1 not taken.
43413 if (count_guys_from_screen(screen) == 0)
21470 {
21471 return;
21472 }
21473
21474 43413 int guycarryingitem = -1;
21475
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 91422 times.
91422 for(int32_t j=0; j<guys.Count(); j++)
21476 {
21477 91422 enemy* e = (enemy*)guys.spr(j);
21478
4/4
✓ Branch 0 taken 69728 times.
✓ Branch 1 taken 21694 times.
✓ Branch 2 taken 26315 times.
✓ Branch 3 taken 43413 times.
91422 if (e->screen_spawned == screen && e->itemguy)
21479 {
21480 43413 guycarryingitem=j;
21481 43413 break;
21482 }
21483 48009 }
21484
21485
2/2
✓ Branch 0 taken 43329 times.
✓ Branch 1 taken 84 times.
43413 if (state.item_state == ScreenItemState::MustGiveToEnemy)
21486 {
21487
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 if(guycarryingitem == -1) //This happens when "default enemies" such as
21488 {
21489 return; //eSHOOTFBALL are alive but enemies from the list
21490 } //are not. Defer to HeroClass::checkspecial().
21491
21492 84 int32_t Item=scr->item;
21493
21494 84 state.item_state = ScreenItemState::None;
21495
21496
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 84 times.
84 if((!getmapflag(screen, mITEM) || (scr->flags9&fITEMRETURN)) && (scr->hasitem != 0))
21497 {
21498 168 auto [x, y] = translate_screen_coordinates_to_world(screen);
21499 236 additem(x,y,Item,ipENEMY+ipONETIME+ipBIGRANGE
21500
2/2
✓ Branch 0 taken 68 times.
✓ Branch 1 taken 16 times.
84 + (((scr->flags3&fHOLDITEM) || (itemsbuf[Item].type==itype_triforcepiece)) ? ipHOLDUP : 0)
21501 );
21502 84 ((item*)items.spr(items.Count() - 1))->screen_spawned = screen;
21503 84 state.item_state = ScreenItemState::CarriedByEnemy;
21504 84 }
21505 else
21506 {
21507 return;
21508 }
21509 84 }
21510
21511
2/2
✓ Branch 0 taken 52922 times.
✓ Branch 1 taken 43413 times.
96335 for(int32_t i=0; i<items.Count(); i++)
21512 {
21513
4/4
✓ Branch 0 taken 49311 times.
✓ Branch 1 taken 3611 times.
✓ Branch 2 taken 5898 times.
✓ Branch 3 taken 43413 times.
52922 if(((item*)items.spr(i))->pickup&ipENEMY && ((item*)items.spr(i))->screen_spawned == screen)
21514 {
21515
2/2
✓ Branch 0 taken 29118 times.
✓ Branch 1 taken 14295 times.
43413 if(get_qr(qr_HIDECARRIEDITEMS))
21516 {
21517 29118 items.spr(i)->x = -128; // Awfully inelegant, innit?
21518 29118 items.spr(i)->y = -128;
21519 29118 }
21520
2/4
✓ Branch 0 taken 14295 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14295 times.
14295 else if(guycarryingitem>=0 && guycarryingitem<guys.Count())
21521 {
21522
1/2
✓ Branch 0 taken 14295 times.
✗ Branch 1 not taken.
14295 if (!get_qr(qr_BROKEN_ITEM_CARRYING))
21523 {
21524 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
21525 {
21526 items.spr(i)->x = guys.spr(guycarryingitem)->x+guys.spr(guycarryingitem)->hxofs+(guys.spr(guycarryingitem)->hit_width/2)-8;
21527 items.spr(i)->y = guys.spr(guycarryingitem)->y+guys.spr(guycarryingitem)->hyofs+(guys.spr(guycarryingitem)->hit_height/2)-10;
21528 }
21529 else
21530 {
21531 if(guys.spr(guycarryingitem)->extend >= 3)
21532 {
21533 items.spr(i)->x = guys.spr(guycarryingitem)->x+(guys.spr(guycarryingitem)->txsz-1)*8;
21534 items.spr(i)->y = guys.spr(guycarryingitem)->y-2+(guys.spr(guycarryingitem)->tysz-1)*8;
21535 }
21536 else
21537 {
21538 items.spr(i)->x = guys.spr(guycarryingitem)->x;
21539 items.spr(i)->y = guys.spr(guycarryingitem)->y - 2;
21540 }
21541 }
21542 items.spr(i)->z = guys.spr(guycarryingitem)->z;
21543 items.spr(i)->fakez = guys.spr(guycarryingitem)->fakez;
21544 }
21545 else
21546 {
21547 14295 items.spr(i)->x = guys.spr(guycarryingitem)->x;
21548 14295 items.spr(i)->y = guys.spr(guycarryingitem)->y - 2;
21549 14295 items.spr(i)->fakez = guys.spr(guycarryingitem)->fakez;
21550 }
21551 14295 }
21552 43413 }
21553 52922 }
21554 15221992 }
21555
21556 14834064 void roaming_item()
21557 {
21558 30056056 for_every_base_screen_in_region([&](mapscr* scr, unsigned int region_scr_x, unsigned int region_scr_y) {
21559 15221992 roaming_item(scr);
21560 15221992 });
21561 14834064 }
21562
21563 bool enemy::IsBigAnim()
21564 {
21565 return (anim == a2FRMB || anim == a4FRM8EYEB || anim == a4FRM4EYEB
21566 || anim == a4FRM8DIRFB || anim == a4FRM4DIRB || anim == a4FRM4DIRFB
21567 || anim == a4FRM8DIRB);
21568 }
21569 2490371 int32_t enemy::getFlashingCSet()
21570 {
21571 //Special cset for the dying sprite
21572
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2490371 times.
2490371 if(dying)
21573 {
21574 if (!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading == fade_blue_poof)
21575 return wpnsbuf[spr_death].csets & 15;
21576 else
21577 return (((clk2 + 5) >> 1) & 3) + 6;
21578 }
21579
21580 //Normal cset
21581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2490371 times.
2490371 if (hclk <= 0)
21582 {
21583 //Special cset for the flashing animation
21584 if (flags & guy_flashing)
21585 return (frame & 3) + 6;
21586 return cs;
21587 }
21588
21589 //Hurt animations
21590
2/2
✓ Branch 0 taken 3888 times.
✓ Branch 1 taken 2486483 times.
2490371 if(type==eeGANON)
21591 3888 return (((hclk-1)>>1)&3)+6;
21592
4/4
✓ Branch 0 taken 2312359 times.
✓ Branch 1 taken 174124 times.
✓ Branch 2 taken 554477 times.
✓ Branch 3 taken 1757882 times.
2486483 else if(hclk<33 && !get_qr(qr_ENEMIESFLICKER))
21593 1757882 return (((hclk-1)>>1)&3)+6;
21594
21595 728601 return cs;
21596 2490371 }
21597
21598 83395497 bool enemy::is_hitflickerframe(bool olddrawing)
21599 {
21600
6/6
✓ Branch 0 taken 83366993 times.
✓ Branch 1 taken 28504 times.
✓ Branch 2 taken 4085526 times.
✓ Branch 3 taken 79281467 times.
✓ Branch 4 taken 3199831 times.
✓ Branch 5 taken 885695 times.
83395497 if (type == eeGANON || !hclk || !get_qr(qr_ENEMIESFLICKER))
21601 82509802 return false;
21602
21603
3/4
✓ Branch 0 taken 609055 times.
✓ Branch 1 taken 276640 times.
✓ Branch 2 taken 609055 times.
✗ Branch 3 not taken.
885695 if (!olddrawing && !getCanFlicker())
21604 return false;
21605
21606 885695 int32_t fr = game->get_spriteflickerspeed();
21607
1/2
✓ Branch 0 taken 885695 times.
✗ Branch 1 not taken.
885695 if (fr == 0)
21608 return true;
21609 885695 return frame % (fr * 2) < fr;
21610 83395497 }
21611
21612 const char *old_guy_string[OLDMAXGUYS] =
21613 {
21614 "(None)","Abei","Ama","Merchant","Moblin","Fire","Fairy","Goriya","Zelda","Abei 2","Empty","","","","","","","","","",
21615 // 020
21616 "Octorok (L1, Slow)","Octorok (L2, Slow)","Octorok (L1, Fast)","Octorok (L2, Fast)","Tektite (L1)",
21617 // 025
21618 "Tektite (L2)","Leever (L1)","Leever (L2)","Moblin (L1)","Moblin (L2)",
21619 // 030
21620 "Lynel (L1)","Lynel (L2)","Peahat (L1)","Zora","Rock",
21621 // 035
21622 "Ghini (L1, Normal)","Ghini (L1, Phantom)","Armos","Keese (CSet 7)","Keese (CSet 8)",
21623 // 040
21624 "Keese (CSet 9)","Stalfos (L1)","Gel (L1, Normal)","Zol (L1, Normal)","Rope (L1)",
21625 // 045
21626 "Goriya (L1)","Goriya (L2)","Trap (4-Way)","Wall Master","Darknut (L1)",
21627 // 050
21628 "Darknut (L2)","Bubble (Sword, Temporary Disabling)","Vire (Normal)","Like Like","Gibdo",
21629 // 055
21630 "Pols Voice (Arrow)","Wizzrobe (Teleporting)","Wizzrobe (Floating)","Aquamentus (Facing Left)","Moldorm",
21631 // 060
21632 "Dodongo","Manhandla (L1)","Gleeok (1 Head)","Gleeok (2 Heads)","Gleeok (3 Heads)",
21633 // 065
21634 "Gleeok (4 Heads)","Digdogger (1 Kid)","Digdogger (3 Kids)","Digdogger Kid (1)","Digdogger Kid (2)",
21635 // 070
21636 "Digdogger Kid (3)","Digdogger Kid (4)","Gohma (L1)","Gohma (L2)","Lanmola (L1)",
21637 // 075
21638 "Lanmola (L2)","Patra (L1, Big Circle)","Patra (L1, Oval)","Ganon","Stalfos (L2)",
21639 // 080
21640 "Rope (L2)","Bubble (Sword, Permanent Disabling)","Bubble (Sword, Re-enabling)","Shooter (Fireball)","Item Fairy ",
21641 // 085
21642 "Fire","Octorok (Magic)", "Darknut (Death Knight)", "Gel (L1, Tribble)", "Zol (L1, Tribble)",
21643 // 090
21644 "Keese (Tribble)", "Vire (Tribble)", "Darknut (Splitting)", "Aquamentus (Facing Right)", "Manhandla (L2)",
21645 // 095
21646 "Trap (Horizontal, Line of Sight)", "Trap (Vertical, Line of Sight)", "Trap (Horizontal, Constant)", "Trap (Vertical, Constant)", "Wizzrobe (Fire)",
21647 // 100
21648 "Wizzrobe (Wind)", "Ceiling Master ", "Floor Master ", "Patra (BS Zelda)", "Patra (L2)",
21649 // 105
21650 "Patra (L3)", "Bat", "Wizzrobe (Bat)", "Wizzrobe (Bat 2) ", "Gleeok (Fire, 1 Head)",
21651 // 110
21652 "Gleeok (Fire, 2 Heads)", "Gleeok (Fire, 3 Heads)","Gleeok (Fire, 4 Heads)", "Wizzrobe (Mirror)", "Dodongo (BS Zelda)",
21653 // 115
21654 "Dodongo (Fire) ","Trigger", "Bubble (Item, Temporary Disabling)", "Bubble (Item, Permanent Disabling)", "Bubble (Item, Re-enabling)",
21655 // 120
21656 "Stalfos (L3)", "Gohma (L3)", "Gohma (L4)", "NPC 1 (Standing) ", "NPC 2 (Standing) ",
21657 // 125
21658 "NPC 3 (Standing) ", "NPC 4 (Standing) ", "NPC 5 (Standing) ", "NPC 6 (Standing) ", "NPC 1 (Walking) ",
21659 // 130
21660 "NPC 2 (Walking) ", "NPC 3 (Walking) ", "NPC 4 (Walking) ", "NPC 5 (Walking) ", "NPC 6 (Walking) ",
21661 // 135
21662 "Boulder", "Goriya (L3)", "Leever (L3)", "Octorok (L3, Slow)", "Octorok (L3, Fast)",
21663 // 140
21664 "Octorok (L4, Slow)", "Octorok (L4, Fast)", "Trap (8-Way) ", "Trap (Diagonal) ", "Trap (/, Constant) ",
21665 // 145
21666 "Trap (/, Line of Sight) ", "Trap (\\, Constant) ", "Trap (\\, Line of Sight) ", "Trap (CW, Constant) ", "Trap (CW, Line of Sight) ",
21667 // 150
21668 "Trap (CCW, Constant) ", "Trap (CCW, Line of Sight) ", "Wizzrobe (Summoner)", "Wizzrobe (Ice) ", "Shooter (Magic)",
21669 // 155
21670 "Shooter (Rock)", "Shooter (Spear)", "Shooter (Sword)", "Shooter (Fire)", "Shooter (Fire 2)",
21671 // 160
21672 "Bombchu", "Gel (L2, Normal)", "Zol (L2, Normal)", "Gel (L2, Tribble)", "Zol (L2, Tribble)",
21673 // 165
21674 "Tektite (L3) ", "Spinning Tile (Combo)", "Spinning Tile (Enemy Sprite)", "Lynel (L3) ", "Peahat (L2) ",
21675 // 170
21676 "Pols Voice (Magic)", "Pols Voice (Whistle)", "Darknut (Mirror) ", "Ghini (L2, Fire) ", "Ghini (L2, Magic) ",
21677 // 175
21678 "Grappler Bug (HP) ", "Grappler Bug (MP) "
21679 };
21680
21681 16717110 int32_t enemy::get_dmisc(byte index)
21682 {
21683
20/33
✓ Branch 0 taken 14611 times.
✓ Branch 1 taken 18181 times.
✓ Branch 2 taken 3236 times.
✓ Branch 3 taken 7390 times.
✓ Branch 4 taken 2144 times.
✓ Branch 5 taken 1799 times.
✓ Branch 6 taken 1056 times.
✓ Branch 7 taken 255 times.
✓ Branch 8 taken 1857 times.
✓ Branch 9 taken 1822 times.
✓ Branch 10 taken 8820348 times.
✓ Branch 11 taken 7597396 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 308 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 40 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 216 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✓ Branch 24 taken 884 times.
✓ Branch 25 taken 1120 times.
✓ Branch 26 taken 331 times.
✓ Branch 27 taken 238061 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 6055 times.
✗ Branch 32 not taken.
16717110 switch (index)
21684 {
21685 14611 case 0: return dmisc1;
21686 18181 case 1: return dmisc2;
21687 3236 case 2: return dmisc3;
21688 7390 case 3: return dmisc4;
21689 2144 case 4: return dmisc5;
21690 1799 case 5: return dmisc6;
21691 1056 case 6: return dmisc7;
21692 255 case 7: return dmisc8;
21693 1857 case 8: return dmisc9;
21694 1822 case 9: return dmisc10;
21695 8820348 case 10: return dmisc11;
21696 7597396 case 11: return dmisc12;
21697 case 12: return dmisc13;
21698 308 case 13: return dmisc14;
21699 case 14: return dmisc15;
21700 40 case 15: return dmisc16;
21701 case 16: return dmisc17;
21702 216 case 17: return dmisc18;
21703 case 18: return dmisc19;
21704 case 19: return dmisc20;
21705 case 20: return dmisc21;
21706 case 21: return dmisc22;
21707 case 22: return dmisc23;
21708 case 23: return dmisc24;
21709 884 case 24: return dmisc25;
21710 1120 case 25: return dmisc26;
21711 331 case 26: return dmisc27;
21712 238061 case 27: return dmisc28;
21713 case 28: return dmisc29;
21714 case 29: return dmisc30;
21715 case 30: return dmisc31;
21716 6055 case 31: return dmisc32;
21717 }
21718
21719 return 0;
21720 16717110 }
21721
21722 312 void enemy::set_dmisc(byte index, int32_t value)
21723 {
21724
3/33
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✓ Branch 26 taken 4 times.
✓ Branch 27 taken 24 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 284 times.
✗ Branch 32 not taken.
312 switch (index)
21725 {
21726 case 0: dmisc1 = value; break;
21727 case 1: dmisc2 = value; break;
21728 case 2: dmisc3 = value; break;
21729 case 3: dmisc4 = value; break;
21730 case 4: dmisc5 = value; break;
21731 case 5: dmisc6 = value; break;
21732 case 6: dmisc7 = value; break;
21733 case 7: dmisc8 = value; break;
21734 case 8: dmisc9 = value; break;
21735 case 9: dmisc10 = value; break;
21736 case 10: dmisc11 = value; break;
21737 case 11: dmisc12 = value; break;
21738 case 12: dmisc13 = value; break;
21739 case 13: dmisc14 = value; break;
21740 case 14: dmisc15 = value; break;
21741 case 15: dmisc16 = value; break;
21742 case 16: dmisc17 = value; break;
21743 case 17: dmisc18 = value; break;
21744 case 18: dmisc19 = value; break;
21745 case 19: dmisc20 = value; break;
21746 case 20: dmisc21 = value; break;
21747 case 21: dmisc22 = value; break;
21748 case 22: dmisc23 = value; break;
21749 case 23: dmisc24 = value; break;
21750 case 24: dmisc25 = value; break;
21751 case 25: dmisc26 = value; break;
21752 4 case 26: dmisc27 = value; break;
21753 24 case 27: dmisc28 = value; break;
21754 case 28: dmisc28 = value; break;
21755 case 29: dmisc30 = value; break;
21756 case 30: dmisc31 = value; break;
21757 284 case 31: dmisc32 = value; break;
21758 }
21759 312 }
21760